更新时间:2023-11-10 17:00:22
预定义的宏列表中没有这样的东西- http://msdn.microsoft.com/zh-CN/library/b0084kay%28v=vs.100%29.aspx 。
There is no such thing in predefined macro list - http://msdn.microsoft.com/en-us/library/b0084kay%28v=vs.100%29.aspx .
但是,默认情况下,如果是静态库项目,MSVC会将 _LIB
添加到预处理器定义列表中。 >
(还会为DLL添加 _USRDLL
)
But by default MSVC adds _LIB
to preprocessor definition list, if it's a "static library" project.
(also it adds _USRDLL
for DLLs)
编辑:在Visual Studio 2017中,DLL的定义为 _WINDLL
(来自IDE应用的 Windows动态链接库属性表)。 _LIB
定义不再可用。
In Visual Studio 2017 the definition for DLLs is _WINDLL
(from the "Windows Dynamic Link Library" property sheet applied by the IDE). The _LIB
definition is no longer available.
另一种解决方案是使用以下预处理器定义向项目添加属性表(签入版本控制存储库): _ $( OutputType);%(PreprocessorDefinitions)
。
An alternative solution is to add a property sheet to the project (checked into your version control repository) with the following preprocessor definition: _$(OutputType);%(PreprocessorDefinitions)
.
$(OutputType)
将解析为DLL的 library和静态库的 staticlibrary,分别导致 _library
和 _staticlibrary
定义(或 _exe
(对于应用程序)。
$(OutputType)
will resolve as "library" for DLLs and "staticlibrary" for static libraries, resulting in _library
and _staticlibrary
definitions respectively (or _exe
for applications).
%(PreprocessorDefinitions)
将堆叠先前属性表中的定义。
%(PreprocessorDefinitions)
will stack definitions from previous property sheets. Make sure it is included in the project properties as well!
要添加属性表,请导航至视图|。其他Windows | Visual Studio中的媒体资源管理器。
To add a property sheet, navigate to View | Other Windows | Property Manager in Visual Studio.