Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 Compiler define

In gcc I am writting friend class FriendMaker<T>::Type but Visual Studio wants friend FriendMaker<T>::Type. So I think it is time to go compiler specific.

So What I need to ifdef for Visual Studio ? I am using 2010 at the moment but I may switch to 2012 latter.

like image 247
Neel Basu Avatar asked Aug 01 '12 07:08

Neel Basu


People also ask

What is CL EXE compiler?

cl.exe is a tool that controls the Microsoft C++ (MSVC) C and C++ compilers and linker. cl.exe can be run only on operating systems that support Microsoft Visual Studio for Windows. Note. You can start this tool only from a Visual Studio developer command prompt.

What is Visual Studio compiler called?

Microsoft Visual C++ (MSVC) is a compiler for the C, C++ and C++/CX programming languages by Microsoft.

Where is the Visual Studio compiler?

As explained above, the Microsoft C/C++ compiler is part of the Windows SDK and is natively included within your Visual Studio installation. More precisely, the default path where you'll find the compiler is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin . The compiler is cl.exe .

Is Visual Studio also a compiler?

Microsoft Visual Studio is a good compiler for developing Windows applications. Although Visual Studio presents a ton of choices to the user when first starting out (for instance, there are a lot of different project types), the amount of choice gives a good idea of the overall scope of this tool.


1 Answers

Use the macro _MSC_VER. To check if the compiler is VS2010, or above:

#if _MSC_VER >= 1600

The following are values for the different versions of VS:

  • VS 2003 (VC7.1): 1310
  • VS 2005 (VC8): 1400
  • VS 2008 (VC9): 1500
  • VS 2010 (VC10): 1600
  • VS 2012 (VC11): 1700
like image 131
hmjd Avatar answered Oct 20 '22 23:10

hmjd