小编use*_*624的帖子

C错误:表达式必须具有常量值

我正在编写一些嵌入式代码,通过SPI与外部设备连接.该设备有几个不同长度的寄存器,为了帮助保持正确,我已经定义了以下结构

typedef struct
{
    uint16_t    Signed          :1;  // Register is signed or unsigned
    uint16_t    CommLengthBytes :3;  // The width of the register in bytes 
    uint16_t    Address         :12; // Register address
}ts_register;
Run Code Online (Sandbox Code Playgroud)

然后,我在源代码中定义了每个寄存器,如下所示

static const ts_register    SAGCYC      = {0, 1, 0x000};
static const ts_register    DISNOLOAD   = {0, 1, 0x001};
static const ts_register    LCYCMODE    = {0, 1, 0x004};
static const ts_register    IRMSA       = {0, 4, 0x31A};
static const ts_register    IRMSB       = {0, 4, 0x31B};
static const ts_register    VRMS        = {0, 4, 0x31C}; …
Run Code Online (Sandbox Code Playgroud)

c arrays compiler-errors

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

c ×1

compiler-errors ×1