C++常见警告
来源:互联网 发布:淘宝时尚女装店名 编辑:程序博客网 时间:2024/05/16 15:06
1. WINVER not defined. Defaulting to 0x0600 (Windows Vista)
如果没有定义WINVER,默认的支持操作系统版本为Vista,可以在工程设置中增加WINVER=0x500;_WIN32_WINNT=0x500; 定义支持的操作系统版本为Win2000。
2. warning C4996: 'strcpy': This function or variable may be unsafe.
C4996的警告是针对C语言中不安全的字符串函数提出的,可以在工程设置中增加宏_CRT_SECURE_NO_WARNINGS来取消这一类的警告。
3. warning C4996: 'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa.
根据ISO C++标准,itoa应当为_itoa。在vs2010下,如果我们把itoa改为_itoa时,编译器照样会在进行警告,告诉我们应该使用_itoa_s来代替_itoa
可以想象,C++标准函数正在逐步向安全性转变
类似的警告有:
warning C4996: 'strupr': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strupr
warning C4996: 'strlwr': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strlwr
4. warning LNK4017: DESCRIPTION statement not supported for the target platform; ignored
VC9的连接器不再支持.def文件中的DESCRIPTION。
5. warning C4244: '=' : conversion from '__time64_t' to 'long', possible loss of data
CTime::GetTime()返回的是__time64_t类型了。
VC9的MFC一些函数返回类型都改成__int64了。
6. warning C4996: 'ATL::CRegKey::QueryValue': CRegKey::QueryValue(TCHAR *value, TCHAR *valueName) has been superseded by CRegKey::QueryStringValue and CRegKey::QueryMultiStringValue
CRegKey有了很多新成员,针对不同的数据类型都有相应的方法:
QueryBinaryValue
QueryDWORDValue
QueryGUIDValue
QueryMultiStringValue
QueryQWORDValue
QueryStringValue
它们能更安全的返回数据,QueryValue已不建议使用。
7. warning C4996: 'CWinApp::Enable3dControlsStatic': CWinApp::Enable3dControlsStatic is no longer needed. You should remove this call.
CWinApp::Enable3dControls和CWinApp::Enable3dControlsStatic都不需要了。
8. warning C4706: assignment within conditional expression
当你写出if (a = b) 或者 if (a = func()) 这样的代码时就会出现这样的警告。有时候if (a = func())确实是你想要的,那么改为if ((a = func()) != NULL)会消除警告。
9. 1>./VehmscX.def : warning LNK4222: exported symbol 'DllCanUnloadNow' should not be assigned an ordinal
1>./VehmscX.def : warning LNK4222: exported symbol 'DllGetClassObject' should not be assigned an ordinal
1>./VehmscX.def : warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal
1>./VehmscX.def : warning LNK4222: exported symbol 'DllUnregisterServer' should not be assigned an ordinal
控件工程编译出的警告,将.def文件中相关函数的序数删掉就可以了。
The following symbols should not be exported by ordinal:
- DllCanUnloadNow
- DllGetClassObject
- DllGetClassFactoryFromClassString
- DllInstall
- DllRegisterServer
- DllRegisterServerEx
- DllUnregisterServer
- keil c 常见错误和警告
- Keil C 编译器常见警告与错误信息的解决方法
- Keil C 编译器常见警告与错误信息的解决方法
- Keil C 编译器常见警告与错误信息的解决方法
- Keil C 编译器常见警告与错误信息的解决方法
- KEIL C编译器常见警告与错误信息的解决办法
- Keil C 编译器常见警告与错误信息的解决方法
- C语言的编译过程常见的错误和警告
- C++常见警告
- Keil常见错误警告
- 常见gcc编译警告
- iOS常见警告解决
- Main.storyboard常见警告
- keil常见警告
- 8051单片机常见警告
- Keil C 中一些常见错误和警告以及对应的解决方案
- Quartus常见警告和错误
- keil mdk 常见警告解析
- 理解Linux中断 (3)
- poj 2001 Shortest Prefixes
- Linux vi常用命令--2
- 把pdf打印到屏幕上台上
- “梁守道”之文人病态
- C++常见警告
- proc文件系统_每进程信息形成原理、目录遍历方式、位图查找
- phonopy 在window下的安装
- 你真的会二分查找吗?
- Linux内核抢占与中断返回
- 利用pthread进行数组求和
- 吐槽不好的交互设计2——便利通
- LL教你入侵网站(算是吧)--对于天津理工教务处网站找回密码方案的建议
- zoj 2947 Abbreviation