LCC: Forward Typedef'd Enum Fail declaration?

The following code snippet compiles on Mac OS X using gcc, but is not compiled on Windows using lcc-win32:

typedef enum Foo Foo; // Other code here enum Foo { Bar = 1 }; 

And gives this error:

unknown enumeration 'foo'

In my particular case, this was not a problem. I just combined the following statements:

 typedef enum Foo { Bar = 1 } Foo; 

But I am wondering if LCC is "more strict" (adhering to some standard) or "more stupid" (the compiler is too dumb to handle this situation).

Thanks.

Also see my other question. LCC: LCC: Initializing structures containing structures?

+4
source share
1 answer

Enumeration declaration variables are non-standard (they violate section C99 6.7.2.3 Β§ 3), and gcc also warns if you add the -pedantic flag (which should be used when writing portable code).

The reason for this is that implementations are free to choose an integer type other than int to use for representing an enumeration (see section 6.99.2.2 Β§99). However, for this, the compiler must see all the values ​​that it must represent before choosing the appropriate type.

+3
source

All Articles