error: #28: expression must have a constant value

error: #28: expression must have a constant value

今天编译一个STM32工程中的下面这段代码,产生了错误

unsigned char i;
char cmd0[] = "MOSKEY(ON)";			//打开MOS管
char cmd1[] = "MOSKEY(OFF)";		//关闭MOS管
char cmd2[] = "MOSKEYTOGGLE";		//MOS管以3s为周期翻转
char cmd3[] = "VoltageMeasurement";	//输入电压检测
char cmd4[] = "matrix on";
char cmd5[] = "matrix off";
char cmd6[] = "digishowstr ";
char cmd7[] = "lcdshowstr ";
char cmdLen[] = //每个命令字符串的长度
{
	sizeof(cmd0)-1,sizeof(cmd1)-1,sizeof(cmd2)-1,sizeof(cmd3)-1,
	sizeof(cmd4)-1,sizeof(cmd5)-1,sizeof(cmd6)-1,sizeof(cmd7)-1
};
char *cmdStr[] = //每个命令字符串的首地址
{
	&cmd0[0],&cmd1[0],&cmd2[0],&cmd3[0],&cmd4[0],&cmd5[0],&cmd6[0],&cmd7[0]
};

下面是报错信息:
error: #28: expression must have a constant value_第1张图片

解决方法:
勾选红框处,再编译,通过了。
error: #28: expression must have a constant value_第2张图片

你可能感兴趣的:(字符串,经验分享)