This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Array initialization inside struct

Hello,
I try compile this code (.c) with --c99 option

struct sx { char c; char a[];
};
static struct sx xx = { 1, {[5] = 0} };

and have error
error: #146: too many initializer values

How to initialize array inside struct ?

ARM C/C++ Compiler, 4.1 [Build 791] [Standard]

Thanks

Parents
  • element a = array of 5 bytes with 0 values

    I wonder where this comes from.
    Even if (as you seem to suggest) the compiler looks at the initializer and uses the highest mentioned array element for the array size, the size would be 6 bytes.
    Anyway, this is beyond standard C99.

Reply
  • element a = array of 5 bytes with 0 values

    I wonder where this comes from.
    Even if (as you seem to suggest) the compiler looks at the initializer and uses the highest mentioned array element for the array size, the size would be 6 bytes.
    Anyway, this is beyond standard C99.

Children