c warning: use of const variable in a constant expression is non-standard in C

后端 未结 1 791
青春惊慌失措
青春惊慌失措 2021-01-14 18:44

I\'m getting this warning when trying to initialize an array to a constant size.

#2170-D use of a const variable in a constant expression is nonstandard in C

相关标签:
1条回答
  • 2021-01-14 18:51

    A const object is not a constant in C but a read-only object. An array declared at file scope (or any array with static storage duration) has to have a constant expression as its number of elements.

    This is valid:

    #define MAXERRORS 4
    LEDSeq errors[MAXERRORS];
    
    0 讨论(0)
提交回复
热议问题