确定何时在VS2010而不是VS2008中使用VC90编译器?
是否有(Microsoft 特定的)CPP 宏来确定我何时在 Visual Studio 2010(而不是 Visual Studio 2008)中使用 VC9 编译器? _MSC_VER
返回编译器版本,因此使用 VS2010 多目标功能,我将得到与 VS2008 相同的结果。
想知道差异的原因是我创建了一个新的 VS2010 项目,其中包含从较大项目中删除的代码。我只是“按原样”保留了 VS2008 的内容,因为无论如何我们“很快”就会离开 VS2008,而且我不想经历创建 vcproj 文件以及新的 vcproj 文件的麻烦。 vcxproj。
现在,我刚刚定义了自己的宏来指示代码是否编译到自己的 DLL 中;它工作得很好,但如果有一些更优雅的东西那就太好了。
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? _MSC_VER
returns the compiler version, so with VS2010 multi-targeting feature, I'll get the same result as with 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. 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.
For now, I've just defined my own macro to indicate whether the code is compiled into its own DLL or not; it works just fine, but it would be nice if there were something slightly more elegant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来这就是您真正想要的(或者我误解了?)。
如果使用 VS2008 的编译器(也容易混淆地称为 VC9 或 cl.exe 15.0),则
_MSC_VER
将返回一个大于或等于 1500 的值。如果 VS2010 的编译器是使用(也称为 VC10 或 cl.exe 16.0),则_MSV_VER
将计算为 1600。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.似乎没有解决方案,自定义宏可以工作,即使它不像我想要的那么优雅。
It seems there is no solution, a custom macro works even if it isn't quite as elegant as I would like.