A question about flexible array members

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

 



Hello,
I've a little question about the GCC extension that allows to put
Flexible Array Members at the end of a struct in the C language.
So basically I can do this:
typedef struct IntArray {
    int x;
    int Data[];
} IntArray;
IntArray array = (IntArray) {0, {1, 2, 3, 4, 5}};
And the generated Assembly code will be:
array:
        .long   0
        .long   1
        .long   2
        .long   3
        .long   4
        .long   5

But why can't I do this?

typedef struct IntArray {
    struct {};
    int Data[];
} IntArray;
IntArray array = (IntArray) {{}, {1, 2, 3, 4, 5}};

What I would want is that all the elements of the array be stored in
the Data member, and not have an extra x member in the struct.




[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