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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top