The following code snippet compiles just fine on Mac OS X with gcc, but fails to compile on Windows with lcc-win32:
typedef struct Foo Foo;
typedef struct Bar Bar;
struct Bar { int age; int height; };
struct Foo { Bar barOne; Bar barTwo; };
// Elsewhere, in some function:
Bar barOne = { 2, 4 };
Bar barTwo = { 6, 8 };
Foo instance = { barOne, barTwo };
And gives this error:
found 'struct Bar' expected 'int'
I can 'overcome' this by initializing the struct this way:
Foo instance = { barOne.age, barOne.height, barTwo.age, barTwo.height };
So, I understand what's going on... but I feel like this makes my code a lot more complex (I need to understand the implementation and layout of the other structs I'm using, instead of simply consuming them - and if that layout changes, I have to spider that change out to anyone else using the struct).
I'm wondering if LCC is being either "more strict" (adhering to some standard) or "more dumb" (the compiler is too dumb to handle this situation).
Thanks.
Also, please see my other LCC-Win32 question: LCC: Forward Declaration of Typedef'd Enum Failing?
Well it's not called the Little C Compiler sometimes for nothing. It can handle most things but to save space and time it will generally be stricter in these cases. Implementing something that looks simple usually isn't in a compiler. Either that or LCC was just never updated to handle these situations. Is there a specific reason for using LCC instead of Borland, MSVC++, Cygin/MingW32 gcc?