Re: Initialization of nested flexible array members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux