Error 28: Expression must have a constant value

风格不统一 提交于 2019-12-13 09:05:33

问题


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?


回答1:


You can force the armcc compiler to use C99 with the --c99 option.



来源:https://stackoverflow.com/questions/24528084/error-28-expression-must-have-a-constant-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!