2011-09-12 45 views
1

我试图复制我的问题的最低限度的例子,用下面的代码:编译错误,而不是VisualStudio的

http://codepad.org/HjhNSk2S

它与Visual Studio 2008完美编译,只显示在键盘一些警告(关于初始化的顺序),但失败,G ++在Cygwin上,给下面的错误,我只是不知道为什么:

Interpolator2.cpp:39: error: expected ‘,’ or ‘...’ before numeric constant 
Interpolator2.cpp: In constructor ‘Interpolator<DIM, SAMPLESTYPE>::Interpolator(const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&)’: 
Interpolator2.cpp:45: error: ‘_wB’ was not declared in this scope 
Interpolator2.cpp:46: error: ‘_sqrDist’ was not declared in this scope 
Interpolator2.cpp:47: error: ‘_kernel’ was not declared in this scope 
Interpolator2.cpp:48: error: ‘_interpolateBins’ was not declared in this scope 
Interpolator2.cpp:49: error: ‘_kNNDist’ was not declared in this scope 
Interpolator2.cpp:50: error: ‘_NLevels’ was not declared in this scope 
Interpolator2.cpp: At global scope: 
Interpolator2.cpp:131: error: expected ‘,’ or ‘...’ before numeric constant 
Interpolator2.cpp: In constructor ‘InterpModeData<DIM, SAMPLESTYPE>::InterpModeData(int, double, const std::vector<std::vector<TsFlow, std::allocator<TsFlow> >, std::allocator<std::vector<TsFlow, std::allocator<TsFlow> > > >&, Vector<DIM, SAMPLESTYPE> (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, double (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&)’: 
Interpolator2.cpp:135: error: ‘_sumWA’ was not declared in this scope 
Interpolator2.cpp:135: error: ‘_sumWB’ was not declared in this scope 
Interpolator2.cpp:135: error: ‘_samples’ was not declared in this scope 
Interpolator2.cpp: In function ‘int main()’: 
Interpolator2.cpp:206: error: no matching function for call to ‘Interpolator<2, double>::Interpolator(std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<double, std::allocator<double> >&, std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<double, std::allocator<double> >&, <unresolved overloaded function type>, <unresolved overloaded function type>, <unresolved overloaded function type>, int, int)’ 
Interpolator2.cpp:43: note: candidates are: Interpolator<DIM, SAMPLESTYPE>::Interpolator(const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&) [with int DIM = 2, SAMPLESTYPE = double] 
Interpolator2.cpp:36: note:     Interpolator<2, double>::Interpolator(const Interpolator<2, double>&) 
Interpolator2.cpp: In member function ‘void Interpolator<DIM, SAMPLESTYPE>::interpolate(double, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, std::vector<double, std::allocator<double> >&) [with int DIM = 2, SAMPLESTYPE = double]’: 
Interpolator2.cpp:212: instantiated from here 
Interpolator2.cpp:58: error: no matching function for call to ‘InterpModeData<2, double>::InterpModeData(unsigned int&, double&, std::vector<std::vector<TsFlow, std::allocator<TsFlow> >, std::allocator<std::vector<TsFlow, std::allocator<TsFlow> > > >&, Vector<2, double> (*&)(const Vector<2, double>&, const Vector<2, double>&, double), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, double (*&)(const Vector<2, double>&, const Vector<2, double>&, double), std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, const std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&)’ 
Interpolator2.cpp:133: note: candidates are: InterpModeData<DIM, SAMPLESTYPE>::InterpModeData(int, double, const std::vector<std::vector<TsFlow, std::allocator<TsFlow> >, std::allocator<std::vector<TsFlow, std::allocator<TsFlow> > > >&, Vector<DIM, SAMPLESTYPE> (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, double (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&) [with int DIM = 2, SAMPLESTYPE = double] 
Interpolator2.cpp:127: note:     InterpModeData<2, double>::InterpModeData(const InterpModeData<2, double>&) 

任何想法? 谢谢!

+1

如果你有一个带有许多参数的构造函数,你应该考虑重构。另外,使用'typedef's!你的代码会更容易阅读。 –

+0

请发布一个最小的代码示例,说明您的实际问题中的问题,而不是链接到其他网站。 –

+0

错误发生在215行文件的第39行......这不是一个极简主义的例子:-)尝试在该行之后删除大量代码,并检查是否仍然收到相同的错误消息。 – user9876

回答

4

使用以下划线后跟大写字母开头的标识符是非法的,例如, _B在线39.

编译器有可能#define d是一个积分常数,这将解释您的错误。尝试将其更改为有效的标识符。

+0

太好了,非常感谢!我不知道,现在编译好:) – WhitAngl

+2

@WhitAngl:在标识符中的任何位置使用双下划线也是非法的。你在这里没有这样做,但很高兴知道:-) –

+2

@Peter:另外,如果在全局命名空间中使用该标识符,则命名一个以单个下划线和小写字母开头的标识符也是非法的。这完成了三个限制:) –