开发者

error: 'Mystruct' undeclared (first use in this function)

开发者 https://www.devze.com 2023-02-10 22:33 出处:网络
I cannot sort a compile time error. I am compiling C project. My main.c file has an #includewhere it can pick up the definition of a structure I am us开发者_如何学Going for my project. The point is th

I cannot sort a compile time error. I am compiling C project. My main.c file has an #include where it can pick up the definition of a structure I am us开发者_如何学Going for my project. The point is that each time that I am trying to compile my code I have the error

struct Mystruct* ps = (struct Mystruct* )malloc( sizeof(Mystruct) ); // I have this
// error at compile time

error: 'Mystruct' undeclared (first use in this function)

How it can be why the compiler is not able to read the structure definition? The include folders are set correctly

Thanks


Sounds like you need to either use sizeof(struct Mystruct) in your expression or use a typedef struct Mystruct Mystruct somewhere. In C, structs have their own namespace.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号