문제

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.

도움이 되었습니까?

해결책 2

It seems there is no solution, a custom macro works even if it isn't quite as elegant as I would like.

다른 팁

_MSC_VER returns the compiler version

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top