Initialization of nested flexible array members
Eljay Love-Jensen
eljay@adobe.com
Tue Oct 7 15:54:00 GMT 2003
Hi Alexandre,
You could try this:
#define DECLARE_MY_STRUCT(len) \
typedef struct { \
char a; \
char b; \
int flexo[len]; \
} EnclosedStruct_##len; \
typedef struct { \
int a; \
int b; \
EnclosedStruct s; \
} MyStruct_##len;
DECLARE_MY_STRUCT(3);
int main(int argc, char * argv[])
{
MyStruct_3 toto = { 10, 20, { 'a', 'b', { 0, 1, 2, 3 } } };
}
If you need to pass a MyStruct_3 to a routine taking a MyStruct*, you can cast it to a MyStruct.
HTH,
--Eljay
More information about the Gcc-help
mailing list