我正在 Visual Studio 2017 版本 15.7 VCToolsVersion 14.14.26428 中开发 C++。
我注意到当我dumpbin
在静态库上运行时,我得到的 _MSC_VER 版本与预期的不同。
为了说明我的问题,我创建了一个静态库 testDumpbin.lib,其中包含一个简单的类 testClass:
测试类.h:
#pragma once
class testClass
{
public:
testClass();
private:
int n;
};
测试类.cpp:
#include "testClass.h"
#include <string>
#define STRING2(x) #x
#define STRING(x) STRING2(x)
#pragma message("")
#pragma message( "_MSC_VER (compiler verion) " STRING(_MSC_VER))
#pragma message("")
testClass::testClass()
{
n = 3;
}
我添加了一些打印 _MSC_VER 宏的预处理器行。
当我在调试模式下编译这段代码时(关闭属性中的预编译头文件 - C/C++),我得到:
1>_MSC_VER (compiler verion) 1914
这是我所期望的,因为我正在运行工具集 14.14(另请参阅https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B)
然后我继续使用dumpbin
(可以从 VS 开发人员命令提示符运行,您可以从 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\LaunchDevCmd.bat 启动):
dumpbin testDumpbinLib.lib /rawdata:1 > dumpbin.log
在那里我发现_MSC_VER = 1900:
00000000: 20 20 20 2F 46 41 49 4C 49 46 4D 49 53 4D 41 54 /FAILIFMISMAT
00000010: 43 48 3A 22 5F 4D 53 43 5F 56 45 52 3D 31 39 30 CH:"_MSC_VER=190
00000020: 30 22 20 2F 46 41 49 4C 49 46 4D 49 53 4D 41 54 0" /FAILIFMISMAT
00000030: 43 48 3A 22 5F 49 54 45 52 41 54 4F 52 5F 44 45 CH:"_ITERATOR_DE
00000040: 42 55 47 5F 4C 45 56 45 4C 3D 32 22 20 2F 46 41 BUG_LEVEL=2" /FA
为什么输出中没有 _MSC_VER = 1914 dumpbin
?
非常感谢你的帮助!