''我在CASE中遇到编译错误'无效常量表达式':我无法理解的switch语句行''
首先,在此之前是否还有其他错误或警告?如果是这样,
你的意思是这一行:
案例PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX:
唯一的常量表达式是PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX - 因此请重新检查该定义。
例如,您是否确定它不受某些条件编译选项的影响,而这些选项在项目中没有(正确)设置...?
Howver,
alert_handle_on_link_loss =(alert_level_t)buffer [0];
也是一个不变的表达 - 你确定它不抱怨吗?
“在这种情况下,我无法理解编译器正在处理异常的问题”
您是否尝试过查看预处理器输出?
请参阅:http://www.8052.com/forum/read/29152
这不是8052特定的 - 确保你没有犯过那里提到的错误!
以上来自于谷歌翻译
以下为原文
''I am getting a compiler error 'Invalid Constant Expression' in the CASE: line of a switch statement that I cannot understand''
First, are there any other errors or warnings before this? If so,
You mean this line:
case PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX:
The only constant expression there is PIPE_LINK_LOSS_ALERT_ALERT_LEVEL_RX - so re-check that definition.
Are you sure it isn't, for example, affected by some conditional compilation options that you've not (properly) set-up in your project...?
Howver,
alert_handle_on_link_loss = (alert_level_t)buffer[0];
is also a constant expression - are you sure it's not complaining about that?
''I cannot understand what the compiler is taking exception to in this case''
Have you tried looking at the preprocessor output?
See: http://www.8052.com/forum/read/29152
It's not 8052-specific - and do make sure that you haven't made the very mistake mentioned there!