Array type has incomplete element type
I'm trying to do this:
typedef struct {
float x;
float y;
} coords;
struct coords texCoordinates[] = { {420, 120}, {420, 180}};
But the compiler won't le开发者_运维百科t me. : ( What's wrong with this declaration? Thanks for your help!
Either do:
typedef struct {
float x;
float y;
} coords;
coords texCoordinates[] = { {420, 120}, {420, 180}};
OR
struct coords {
float x;
float y;
};
struct coords texCoordinates[] = { {420, 120}, {420, 180}};
In C, struct
names reside in a different name space than typedef
s.
Of course you can also use typedef struct coords { float x; float y; } coords;
and use either struct coords
or coords
. In this case it won't matter what you choose, but for self-referencing structures you need a struct name:
struct list_node {
struct list_node* next; // reference this structure type - need struct name
void * val;
};
精彩评论