[英]Determine when using the VC90 compiler in VS2010 instead of VS2008?
Is there a (Microsoft-specific) CPP macro to determine when I'm using the VC9 compiler in Visual Studio 2010 as opposed to Visual Studio 2008? 是否有一个(特定于Microsoft的)CPP宏来确定我何时在Visual Studio 2010中使用VC9编译器而不是Visual Studio 2008?
_MSC_VER
returns the compiler version, so with VS2010 multi-targeting feature, I'll get the same result as with VS2008. _MSC_VER
返回编译器版本,因此使用VS2010多目标功能,我将获得与VS2008相同的结果。
The reason for wanting to know the difference is that I created a new VS2010 project which contains code removed from a larger project. 想要知道差异的原因是我创建了一个新的VS2010项目,其中包含从较大项目中删除的代码。 I just left the VS2008 stuff "as is" since we're moving away from VS2008 "soon" anyway and I didn't want to go through the hassle of creating a vcproj file along with the new vcxproj .
我只是“原样”离开了VS2008的东西,因为无论如何我们都将很快离开VS2008,并且我不想经历创建vcproj文件和新的vcxproj的麻烦 。
For now, I've just defined my own macro to indicate whether the code is compiled into its own DLL or not; 现在,我只是定义了自己的宏以指示代码是否已编译到其自己的DLL中。 it works just fine, but it would be nice if there were something slightly more elegant.
它工作得很好,但是如果有一些更优雅的东西,那就太好了。
_MSC_VER
returns the compiler version_MSC_VER
返回编译器版本
It sounds like that's what you really do want (or am I misunderstanding?). 听起来这就是您真正想要的(或者我误会了吗?)。
If the compiler from VS2008 (which confusingly is also known as VC9 or cl.exe 15.0) is being used, then _MSC_VER
will return a value that's greater than or equal to 1500. If the compiler from VS2010 is used (also known as VC10 or cl.exe 16.0), then _MSV_VER
will evaluate to 1600. 如果使用的是VS2008的编译器(令人困惑的也称为VC9或cl.exe 15.0),则
_MSC_VER
将返回一个大于或等于1500的值。如果使用了VS2010的编译器(也称为VC10或cl.exe 16.0),则_MSV_VER
值为1600。
似乎没有解决方案,即使自定义宏不是我想要的那么优雅,它也可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.