看流星社区

 找回密码
 注册账号
查看: 1753|回复: 0

VC6工程转VC9工程常见警告

[复制链接]

该用户从未签到

发表于 2015-3-28 16:42:09 | 显示全部楼层 |阅读模式
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。

类似的警告有:

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
点击按钮快速添加回复内容: 支持 高兴 激动 给力 加油 苦寻 生气 回帖 路过 感恩
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小黑屋|手机版|Archiver|看流星社区 |网站地图

GMT+8, 2024-3-29 14:24

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

快速回复 返回顶部 返回列表