AVR GCC 错误初始值设定项元素不是常量

AVR GCC Error initializer element is not constant

我正在使用 Atmel Studio 6.2,芯片 xmega64D3,我在初始化结构的某些字段时遇到问题:

typedef struct
{
    uint32_t val;
    uint32_t inv;
    uint32_t xor;
}SPROTU32;

typedef struct
{
    SPROTU32 SerialNr;
    SPROTU32 SwVersion;
    SPROTU32 HwVersion;
    SPROTU32 ProdCode;
    SPROTU32 ProdDate;
    SPROTU32 PartNum;
}BasicData;

#define sw_high                     02
#define sw_low                      12
#define sw_ver                      ((sw_high << 16) + sw_low)

#define hw_high                     01
#define hw_low                      06
#define hw_ver                      ((hw_high << 16) + hw_low)

#define DEFAULT_SERIAL              0
#define DEFAULT_SW_VERSION          sw_ver
#define DEFAULT_HW_VERSION          hw_ver
#define DEFAULT_PROD_CODE           0
#define DEFAULT_PROD_DATE           0
#define DEFAULT_PART_NUM            05545410

EEMEM BasicData eeBasicData =
{
    {DEFAULT_SERIAL,~DEFAULT_SERIAL,DEFAULT_SERIAL^0x55555555},
    {DEFAULT_SW_VERSION,~DEFAULT_SW_VERSION,DEFAULT_SW_VERSION^0x55555555},
    {DEFAULT_HW_VERSION,~DEFAULT_HW_VERSION,DEFAULT_HW_VERSION^0x55555555},
    {DEFAULT_PROD_CODE,~DEFAULT_PROD_CODE,DEFAULT_PROD_CODE^0x55555555},
    {DEFAULT_PROD_DATE,~DEFAULT_PROD_DATE,DEFAULT_PROD_DATE^0x55555555},
    {DEFAULT_PART_NUM,~DEFAULT_PART_NUM,DEFAULT_PART_NUM^0x55555555}
};

Compile output image

编译器说 always initilizer 不是常量。那么,我该怎么做才能用我想要的东西初始化我的结构?

尝试使用乘法运算代替 << 运算

 #define _VERSION(h,l) ((h * 65536) | l)
 #define DEFAULT_SW_VERSION _VERSION(sw_high, sw_low)