error: 'Mystruct' undeclared (first use in this function)
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.
精彩评论