C error: expression must have a constant value

后端 未结 3 1942
逝去的感伤
逝去的感伤 2020-12-11 20:01

I am writing some embedded code to interface with an external device over SPI. The device has several registers of varying length and to help keep things straight I have def

3条回答
  •  一整个雨季
    2020-12-11 20:47

    Since they are defined as constants, what have I overlooked?

    In C objects declared with the const modifier aren't true constants. A better name for const would probably be readonly - what it really means is that the compiler won't let you change it. And you need true constants to initialize objects with static storage (I suspect regs_to_read is global).

    You could try assigning regs_to_read in a function called before anything else uses that array.

提交回复
热议问题