Error compiling gcc to plain code

I need help with a simple c structure and can't find it, why it doesn't compile with gcc (opensuse 11.4)

I have this code:

 struct Image { int w; int h; // other code }; 

in the same file, I have another structure array similar to this:

 struct ShapeImage { Image image[10]; // other code }; 

when compiling, I get:

 syntax error before [' token` 

Why am I getting this error if I specify the number 10 in the image image[10]; Looks good to me, what's wrong?

+6
source share
1 answer

It should be:

 struct Image image[10] ; 

Or use typedef when defining the structure:

 typedef struct { int w; int h; // other code } Image; 

And use the code differently as in your question.

+16
source

Source: https://habr.com/ru/post/901570/


All Articles