我用vs2008编译UE3工程,前面几个都好好的就是到了D3DDrv这个库时,出现编译错误,如下:
development\src\d3ddrv\src\D3DStats.h(27) : error
C2785: 'T InitialStatValue(void)' and 'FD3DCounter InitialStatValue(void)' have
different return types
development\src\d3ddrv\src\D3DStats.h(27) : error
C3637: 'InitialStatValue' : a friend function definition cannot be a
specialization of a function template
development\src\d3ddrv\src\D3DStats.h(27) : error
C2912: explicit specialization; 'FD3DCounter InitialStatValue(void)' is not a
specialization of a function template
最后在一个国外的论坛找到解决方法:
class FD3DCounter
{

template <class FD3DCounter> friend FD3DCounter InitialStatValue(FD3DCounter()) {    
return FD3DCounter();    
}
    // Constructor.
public:

DWORD            RenderCycles,
        WaitCycles,
        Pixels;

FD3DCounter():
        RenderCycles(0),
        WaitCycles(0),
        Pixels(0)
    {}
};
注意这个时候还要改友元函数。

template
<class T> T InitialStatValue(int FD3DCounter&) { return 0; }

改为
template <class T> friend T InitialStatValue(T()) { return T(); }
这样编译可以用过。
看来真的要好好复习下C++模板了。