AnsweredAssumed Answered

Struct initialization - Compiller error

Question asked by Martin Kresta on Sep 11, 2012
Latest reply on Sep 11, 2012 by CrasyCat

Hi,

I am using Codewarrior 5.9 with target MC9S12XS128.

 

I am trying to initialize array of structures. But I end up with following error.

 

in header file:

typedef struct {

  uint8 mask;

  uint8 offset;

  Dio_PortType port;         

} Dio_ChannelGroupType;         // Definition of channel group


in another header file:

extern const Dio_ChannelGroupType DioConfigData[];


in .c file:

const Dio_ChannelGroupType DioConfigData[] = {

    {

        .mask = 0xF0U,     error: Expected: . * = - & ! ~ ++ -- -> [ ( IDENT CONSTANT STRING sizeof __alignof__ __va_sizeof__ __va_arg_type__

        .offset = 4U,

        .port = P_T,

    },  

    {

        .mask = 0x0FU,

        .offset = 0U,

        .port = P_A,

    }

}; 

 

This construction works without errors on the same place :

const Dio_ChannelGroupType DioConfigData[] = {

    {

        0xF0U,

        4U,

        P_T,

    },  

    {

        0x0FU,

        0U,

        P_A,

    }

};


I have no clue what is wrong with my code. Do you have any advice?

Thank you


Martin


 


Outcomes