错误28:表达式必须具有常量值 [英] Error 28: Expression must have a constant value
问题描述
我有一个c ++代码在keil uvision5的部分,得到错误28:表达式必须有一个常量的值。我想弄清楚如何修复它。
I have a section of c++ code in keil uvision5 that is getting error 28: expression must have a constant value. I am trying to figure out how to fix it.
这是一行(函数内部),它发生在:
this is the line (inside of a function) that it is happening on:
osPoolDef_t pool_def = { queue_def->queue_sz, queue_def->item_sz};
它不喜欢变量queue_sz或item_sz。
it does not like the variables queue_sz or item_sz.
这里是osPoolDef_t的定义:
here is the definition of osPoolDef_t:
typedef const struct os_pool_def {
uint32_t pool_sz; /* number of items (elements) in the pool */
uint32_t item_sz; /* size of an item */
void *pool; /* pointer to memory for pool */
} osPoolDef_t;
,queue_def是指向osMailQDef_t的指针,如下所示:
and queue_def is a pointer to osMailQDef_t shown below:
typedef const struct os_mailQ_def {
uint32_t queue_sz; /* number of elements in the queue */
uint32_t item_sz; /* size of an item */
struct os_mailQ_cb **cb;
} osMailQDef_t;
希望这是足够的信息。
似乎问题是,我不再使用c99,但代码工作正常的文件,当我使用c99。有没有办法强制编译的只是那个文件用c99完成
It seems that the problem is that I am not using c99 anymore, but the code worked fine for that file when I used c99. Is there a way to force the compilation of just that file to be done with c99?
推荐答案
你可以强制armcc编译器请使用C99与--c99选项。
You can force the armcc compiler to use C99 with the --c99 option.
这篇关于错误28:表达式必须具有常量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!