Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


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

const struct/unon initialization proble.

Hi,

with the following sample code...

typedef __packed struct
{
        uint8_t field_1;
        uint8_t field_2;
        uint8_t field_3;
        uint8_t field_4;
} T_Sub;

typedef __packed struct
{
        T_Sub   Sub;
        uint8_t field_1;
        uint8_t field_2;
        uint8_t field_3;
        uint8_t field_4;
} T_Data;

typedef __packed union
{
        T_Data  content;
        uint8_t buffer[sizeof(T_Data)];
} T_Union;

const T_Union C_Union = { {1,2,3,4}, 1, 2, 3, 4, 5};

// The following (no union, just strcut) has the same problem
/*
typedef __packed struct
{
        T_Data  content;
} T_Struct;

const T_Struct C_Struct = { {1,2,3,4}, 1, 2, 3, 4, 5};
*/


I get:

error:  #146: too many initializer values

I'm using uVision4.
The same code works on other compilers. I'm obviously missing something big but I can't figure what...

Parents Reply Children
No data