VS2010 compiler defines

In gcc, I write friend class FriendMaker<T>::Type , but Visual Studio wants friend FriendMaker<T>::Type . So I think it's time to move on to the compiler.

So what do I need for ifdef for Visual Studio ? I am using 2010 at the moment, but I can switch to 2012 last.

+6
source share
3 answers

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

 #if _MSC_VER >= 1600 

The following are the values ​​for 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
+17
source

Just use friend class ... syntax for both compilers. friend ... syntax friend ... without the class keyword, is actually invalid; VS2010 is incorrect without complaining about it.

See this question .

0
source

I think you need to use the following code for the cross-compiler:

 template <typename T> class B; template <typename T> class A { friend typename B<T>::V; }; 
0
source

Source: https://habr.com/ru/post/921826/


All Articles