On Tue, Jul 19, 2011 at 2:56 PM, Cheng Renquan <crq...@gmail.com> wrote:
> Hi all,
>
> From info gcc I know it accepts a series of `.FIELDNAME' and `[INDEX]'
> designators,
> like
>
>     struct point ptarray[10] = { [2].y = yv2, [2].x = xv2, [0].x = xv0 };
>
>
> But in my case, I have a struct with array of int as members,
>
>     struct mbox {
>       int x[20];
>       int y[20];
>     };
>
> and want to declare a mbox variable with partially initialized, like
>
>     struct mbox mbox = { .x = { 1, 2 }, .y[19] = 3, };

Sorry, my above example is not good, it compiles and works ok;

What's really not working is this example by union:

      union mbox {
          int   w[3];
          short s[6];
          char  c[12];
      };

If I declare a union mbox and want to initialize w[0], s[2] and c[6],

  union mbox mbox = { .w = { 1, }, .s[2] = 2, .c[6] = 's' };

I want a mbox initialized with these 12 bytes (on little endian):

0000:   01 00 00 00 02 00 73 00  00 00 00 00

And actually I got these:

0000:   00 00 00 00 00 00 73 00  00 00 00 00

the hexdump result shows only last .c[6] make effect,

Wonder if this is a bug or not supported? Thanks,

Reply via email to