根据VC++条件编译编译器版本
我正在将 VC++ 项目从 Visual Studio 2005 (VC8) 迁移到 Visual Studio 2008 (VC9)。解决方案中的某些项目在项目设置的“其他库目录”字段中具有第三方库的路径。路径看起来像这样:
..\SomeLibrary\Lib\vc9\x86
如果我可以使用 Visual Studio 的“属性页宏”之一来替换编译器版本,这将非常有用,就像我可以使用 $(ConfigurationName) 来替换一样用于“调试”或“发布”。像下面这样的东西就完美了:
..\SomeLibrary\Lib\$(CompilerVersion)\x86
不幸的是,我找不到合适的宏。
请注意,当我说“宏”时,我指的是 Visual Studio 的“属性页宏”,而不是 C/C++ 预处理器宏。据我所知,您不能在项目设置中使用预处理器指令。
有谁知道有什么方法可以做到这一点?
I am in the process of migrating our VC++ project from Visual Studio 2005 (VC8) to Visual Studio 2008 (VC9). Some of the projects in the solution have paths to third party libraries in their 'Additional Library Directories' field in the project settings. The paths look something like this:
..\SomeLibrary\Lib\vc9\x86
It would be really useful if I could use one of Visual Studio's "Property Page Macros" to substitute for the compiler version, in much the same way as I can use $(ConfigurationName) to substitue for "Debug" or "Release". Something like the following would be perfect:
..\SomeLibrary\Lib\$(CompilerVersion)\x86
Unfortunately, I can't find an appropriate macro.
Please note that when I say 'macro' I am refering to Visual Studio's "Property Page Macros", not C/C++ preprocessor macros. As far as I am aware you can't use preprocessor directives in the project settings.
Does anyone know of a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
_MSC_VER
:有关更复杂的示例,请参阅 boost 如何处理 VC++ 版本 此处
Use
_MSC_VER
:For a more complicated example, see how boost is dealing with VC++ versions here
您可以使用属性页宏 $(PlatformToolsetVersion) 或 $(PlatformToolset)
例如,对于 vc++ 2012,$(PlatformToolsetVersion) 解析为“110”,$(PlatformToolset) 解析为“v110”。因此,将“vc$(PlatformToolsetVersion)”添加到路径中会在 vc11 下添加“vc110”,或在 vc9 下添加“vc90”。
You could use the property page macros $(PlatformToolsetVersion) or $(PlatformToolset)
For vc++ 2012, for example, $(PlatformToolsetVersion) resolves to "110" and $(PlatformToolset) resolves to "v110". So adding "vc$(PlatformToolsetVersion)" to your path would add "vc110" under vc11 or "vc90" under vc9.
您是否尝试过
_MSC_VER
。对于 Microsoft 的 C++ 编译器,这将给出编译器的主要版本号和次要版本号。它可以用作分隔符。Have you tried
_MSC_VER
. For Microsoft`s C++ compiler this will give the major and minor version number of the compiler. It could be used as the delimeter.