【发布时间】:2011-11-05 18:27:10
【问题描述】:
以下代码使用 MSVC 2008 编译良好。当您构建 GCC 时,会出现很多错误(代码后出现错误)。应该怎么做才能解决这个错误?
#define FORCE_INLINE inline
#define CREF(A) const A&
template <class F>
class RDOFunCalcStd: public RDOFunCalc
{
...
template <int paramCount>
FORCE_INLINE void calc(CREF(LPRDORuntime) pRuntime);
template <>
FORCE_INLINE void calc<1>(CREF(LPRDORuntime) pRuntime)
{
m_value = m_pFunction(getParam<F::arg1_type>(pRuntime, 0));
}
template <>
FORCE_INLINE void calc<2>(CREF(LPRDORuntime) pRuntime)
{
m_value = m_pFunction(getParam<F::arg1_type>(pRuntime, 0), getParam<F::arg2_type>(pRuntime, 1));
}
};
GCC 提供以下错误:
error: too many template-parameter-lists
error: explicit specialization in non-namespace scope ‘class rdoRuntime::RDOFunCalcStd<F>’
error: variable or field ‘calc’ declared void
error: expected ‘;’ before ‘<’ token
error: expected ‘;’ before ‘template’
error: explicit specialization in non-namespace scope ‘class rdoRuntime::RDOFunCalcStd<F>’
error: variable or field ‘calc’ declared void
error: expected ‘;’ before ‘<’ token
【问题讨论】:
标签: c++ templates visual-c++ gcc syntax