2011-11-05 57 views
0

下面的代码,编译罚款MSVC,但是当构建GCC提供了很多的错误:错误模板偏特在编译GCC,但不是MSVC

#define FORCE_INLINE inline 
#define CREF(A) const A& 

template <class F> 
class RDOFunCalcStd: public RDOFunCalc 
{ 
... 
template <class T> 
FORCE_INLINE T getParam(CREF(LPRDORuntime) pRuntime, ruint paramNumber); 

template <> 
FORCE_INLINE double getParam<double>(CREF(LPRDORuntime) pRuntime, ruint paramNumber) 
{ 
    return pRuntime->getFuncArgument(paramNumber).getDouble(); 
} 

template <> 
FORCE_INLINE int getParam<int>(CREF(LPRDORuntime) pRuntime, ruint paramNumber) 
{ 
    return pRuntime->getFuncArgument(paramNumber).getInt(); 
} 
... 
}; 

错误列表:

error: explicit specialization in non-namespace scope ‘class rdoRuntime::RDOFunCalcStd’

error: template-id ‘getParam’ in declaration of primary template

error: explicit specialization in non-namespace scope ‘class rdoRuntime::RDOFunCalcStd’

error: template-id ‘getParam’ in declaration of primary template

error: ‘int rdoRuntime::RDOFunCalcStd::getParam(const rdoRuntime::LPRDORuntime&, ruint)’ cannot be overloaded

error: with ‘double rdoRuntime::RDOFunCalcStd::getParam(const rdoRuntime::LPRDORuntime&, ruint)’

应该做些什么来解决错误?

回答