在 gcc 我正在写friend class FriendMaker<T>::Type,但 Visual Studio 想要friend FriendMaker<T>::Type. 所以我认为是时候去编译特定的了。
那么我需要ifdef做什么Visual Studio?我目前使用的是 2010,但以后可能会切换到 2012。
在 gcc 我正在写friend class FriendMaker<T>::Type,但 Visual Studio 想要friend FriendMaker<T>::Type. 所以我认为是时候去编译特定的了。
那么我需要ifdef做什么Visual Studio?我目前使用的是 2010,但以后可能会切换到 2012。
使用宏_MSC_VER。检查编译器是否为 VS2010 或更高版本:
#if _MSC_VER >= 1600
以下是不同版本 VS 的值:
13101400150016001700只需使用friend class ...两个编译器的语法。没有关键字的friend ...语法class实际上是无效的;VS2010 不抱怨它是不正确的。
看到这个问题。
我认为您需要使用以下代码进行交叉编译:
template <typename T> class B;
template <typename T>
class A
{
friend typename B<T>::V;
};