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};
it does not like the variables queue_sz or item_sz.
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;
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;
hopefully that is enough information.
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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…