warning 的消除方法

来源:互联网 发布:java notempty 编辑:程序博客网 时间:2024/04/30 11:32

一般来说,警告没有什么影响,但是太多的warning看着都眼花,也不太好看,所以还是需要把他们都禁掉。

 warning C4127: conditional expression is constant
warning C4127: conditional expression is constant
warning C4127: conditional expression is constant

第一个方法:直接去project -->properties-->configuration properties-->c/c++ -->advanced --> disable specific warning 中添加相应的编号 即可

第二方法:直接在文件编译头添加#pragma warning(disable:编号)就可以了。

下面这个warning 虽然见的少,单也是必须了解处理他的方法

warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

出现这个警告可能不能再debug状态下加断点操作,所以这个warning还必须进行改正,要不影响调试。不过,我暂时用的都不是unicode,直接设置都是not set,

也可以用网上搜到的方法:打开出现warning的文件,Ctrl+A全选, 然后在文件菜单:file->advanced save options, 在弹出的选项中选择编码方式为UINCODE codepage 1200,点确定就可以解决。

还有一类warning比如:

 warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

这个解决方法:project -->properties-->configuration properties-->c/c++ -->preprocessor 里面的preprocessor definitions 里面把 _CRT_SECURE_NO_WARNINGS加进去就ok了。



0 0
原创粉丝点击