简体   繁体   English

在g ++而不是VisualStudio上编译错误

[英]compile error on g++ and not VisualStudio

I tried to replicate a minimalist example of my problem, with the following code : 我尝试使用以下代码复制我的问题的极简主义示例:

http://codepad.org/HjhNSk2S http://codepad.org/HjhNSk2S

It does compile perfectly with Visual Studio 2008, just displays some warnings on codepad (about the order of initialization), but fails with g++ on cygwin, giving the following errors, and I just have no clue why : 它确实与Visual Studio 2008完美编译,只是在键盘上显示一些警告(关于初始化的顺序),但在cygwin上使用g ++失败,出现以下错误,我只是不知道为什么:

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>&)

Any idea ? 任何想法 ? Thanks!! 谢谢!!

It is illegal to use identifiers that begin with an underscore followed by an uppercase letter, eg _B on line 39. 使用以下划线后跟大写字母开头的标识符是非法的,例如第39行上的_B

The compiler has probably #define d that to be an integral constant, which would explain your error. 编译器可能#define d是一个整数常量,这可以解释你的错误。 Try changing it to a valid identifier. 尝试将其更改为有效的标识符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM