expected specifier-qualifier-list before ‘Button’

What if you make a new struct, wich has a structmember that is a pointer to something that has the same type of the struct you are making?

For example:
typedef struct
{
char* text;
u8 posX;
u8 posY;
u8 width;
u8 height;
void* callback_function;
Button* array;
u8 itemsInArray;
} Button;

Now you will get the following error:  expected specifier-qualifier-list before ‘Button’
How to work around this?
Put struct in front of the structmember, and it will compile!

Working example:
ypedef struct
{
char* text;
u8 posX;
u8 posY;
u8 width;
u8 height;
void* callback_function;
struct Button* array;
u8 itemsInArray;
} Button;

Note:
The button-struct is not a very good struct itself, but it’s an example for this error.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: