【发布时间】:2011-02-11 14:00:57
【问题描述】:
我们正在获取一些为 Visual Studio 2008 编写的代码,并尝试使用 gcc 对其进行编译。我们在以下代码中遇到错误(简化为必要的):
template<int R, int C, typename T>
struct Vector
{
template <typename TRes>
TRes magnitude() const
{
return 0;
}
};
struct A
{
typedef Vector<3,1,int> NodeVector;
};
template<class T>
struct B
{
void foo()
{
typename T::NodeVector x;
x.magnitude<double>(); //< error here
}
};
...
B<A> test;
test.foo();
GCC 说
error: expected primary-expression before 'double'
error: expected `;' before 'double'
你能解释一下这个错误吗?什么是交叉编译器解决方案?
非常感谢!
【问题讨论】:
-
键盘链接 - 这有效吗? - codepad.org/s5G0Cf6D