SSE*_*ber 4 compiler-errors visual-studio
当我尝试编译此代码时,出现Case Expression Not Constant错误.我无法弄清楚为什么.
while ((*datalen) == 0)
crReturn(NULL); //error here
st->len = (st->len << 8) + **data;
Run Code Online (Sandbox Code Playgroud)
函数crReturn()定义如下.
#define crReturn(z) \
do {\
*crLine =__LINE__; return (z); case __LINE__:;\
} while (0)
Run Code Online (Sandbox Code Playgroud)
Gar*_*han 10
问题是,MSVC++做了非标准(和违背自己的文档)时,它的配置生成调试信息的"编辑并继续"功能,并且这种非标准打破的方式__LINE__在西蒙泰胜的协程宏使用.
以下是PuTTY源代码中的注释对此的说法:
In particular, if you are getting `case expression not constant'
errors when building with MS Visual Studio, this is because MS's
Edit and Continue debugging feature causes their compiler to
violate ANSI C. To disable Edit and Continue debugging:
- right-click ssh.c in the FileView
- click Settings
- select the C/C++ tab and the General category
- under `Debug info:', select anything _other_ than `Program
Database for Edit and Continue'.
Run Code Online (Sandbox Code Playgroud)
所以你应该这样做.(事实上,我知道你已经这样做了,因为我在发表这个答案之前在评论中对此进行了讨论:-).)
| 归档时间: |
|
| 查看次数: |
1564 次 |
| 最近记录: |