Re: Initialization of nested flexible array members

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

 



This is a hack, but you may give it a try:

typedef struct
{
    char a;
    char b;
    int flexo[0];
} EnclosedStruct;

typedef struct
{
    int a;
    int b;
    EnclosedStruct s;
    int flexo[];
} MyStruct;

MyStruct toto = { 10, 20, { 'a', 'b'},{ 0, 1, 2, 3 }  };
int main(int argc, char * argv[])
{
    int i;
    for(i=0;i<4;i++)
      printf("%d\n",toto.s.flexo[i]);
}



Alexandre Courbot wrote:

Declare your stretchy-buffered struct this way:

typedef struct
{
   char a;
   char b;
   int flexo[1024];
} EnclosedStruct;

Instead of "1024", use whatever largest possible size the struct could
conceivably need to accommodate.


This is unfortunately not an option, since the code is designed to run on constraint embedded targets with 1K RAM at best... :)

Alex.





[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