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 let 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;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With