nested struct

S

softwareEngineer

Hi All,
I'm compiling this (external) code :

<CODE>
typedef struct _SIZE
{
int size_a;
int size_b;
}SIZE;

typedef struct _FOO
{
int a;
int b;

struct BAR
{
int x;
int y;
}BAR;

}FOO;

static SIZE mysize = { sizeof(struct BAR), sizeof(struct BAR) }; // <---- Error ...

int main (int argc, char *argv[])
{
printf(":: SERVER START :: \n");

printf ("SIZEOF BAR = %d \n", mysize.size_a);

printf(":: SERVER END :: \n");
return 0;
}
</CODE>

It gave this error :
--> server.c:25: error: invalid application of ‘sizeof’ to incomplete type ‘BAR’
Unique solution is to move "struct BAR" out from struct FOO ?

thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top