OpenEdv-开源电子网

标题: IAR环境编译expression must have a constant value错误 [打印本页]

作者: 汪志鹏    时间: 2018-11-18 13:44
标题: IAR环境编译expression must have a constant value错误
在IAR环境中有下面的代码,会出现Error[Pe028]: expression must have a constant value 错误,但是MDK的环境就不会出现,




能有大神帮忙看一下.


static const int buff[] =
{
1,
2,
3,
};

static const int Count = sizeof( buff ) / sizeof( int );
static uint16 Time[ Count ] = {0};        /* polling time array */

作者: 汪志鹏    时间: 2018-11-18 14:04
帮顶,

作者: way2888    时间: 2018-11-19 04:46
定义数组时必须是具体的数值,不能为变量,非要这么做就使用动态申请内存吧
作者: szczyb1314    时间: 2018-11-19 10:16
Time数组定义需要确定的大小
const修饰的常量,其实也是变量只是你修改的时候会有警告,用宏定义吧




欢迎光临 OpenEdv-开源电子网 (http://47.111.11.73/) Powered by Discuz! X3.4