【发布时间】:2015-12-23 06:18:18
【问题描述】:
我有一些代码可以用 gcc 很好地编译,但 Visual Studio 不喜欢。我把它提炼成一个最小的例子:
#include "stdafx.h"
#include <Eigen/Dense>
template<class Base>
class Timestamp : public Base
{
public:
typedef typename Base::PointType PointType;
double timestamp;
};
/*
struct Point {};
struct PointXYZ : public Point
{
typedef PointXYZ PointType;
};
*/
struct PointXYZ : public Eigen::Vector3d
{
typedef PointXYZ PointType;
};
int _tmain(int argc, _TCHAR* argv[])
{
Timestamp<PointXYZ> point;
return 0;
}
错误是"error C2039: 'PointType' : is not a member of 'Eigen::PlainObjectBase<Derived>'"
PlainObjectBase 类是 Eigen 库的一部分。如果我将 PointXYZ 的定义替换为 cmets 中派生自一个空“Point”类的定义,它在 VS 中也可以正常编译。关于为什么会发生这种情况以及 VS 可以改变什么以像 gcc 那样接受它的任何建议?
【问题讨论】: