C++遇到的一些错误

1.invalid declarator before ‘PointCloud’

这个其实是犯了一个错误,一般报错类型如下:

invalid declarator before ...

这个错误要在定义这个函数原型的文件进行查找,看是否定义正确,或者整个头文件的定义是否完整。LZ在头文件中定义文件没有错误,但是在头文件定义的结构体最后没加“;”,这个就很尴尬,查函数原型查了那么就,结果发现这个错误是有些崩溃的,还是细心为上!

2. error: unterminated #ifndef

1.权限问题

2.少了#endif (LZ犯得第二个弱智错误。。。)

3.expected ‘(’ before ‘,’ token

这个错误应该还是比较常见的,在’,‘前面少了’(‘;这种错误算是比较低级的,有个小伙伴说凡是编译器能报的错都是比较低级的错误,如果是逻辑上的错,编译器不报错,那就欲哭无泪,只能按照逻辑逐个排查了。

4.expected ’;‘ before ’}‘ token

在’}‘前少了一个分号

5.’cloud‘ was not declared in this scope

变量没有定义,C++有的时候真的还是比较麻烦的,用惯了matlab会不是很习惯。。。

6.prototype for ’int class::function()‘ does not match any in class ’ ‘

这个问题是头文件定义的类的函数的类型和定义函数或者调用该函数时类型不匹配,比如在头文件的函数原型定义为int,然后在具体定义函数的时候写成void,那么从本质上来说这两个函数并不是一致的,计算机自然找不到。

7.no pre-increment operator for type ++count

这个问题还是出现在没有定义变量count,所以计算机没法运算++,默认定义的初始值是0。

8. error: name lookup of ‘m’ changed for ISO ‘for’ scoping [-fpermissive]

m的作用域范围是函数作用域,在for循环外使用就会报这种错,如果想在for循环外继续使用这个变量,可以在for循环外定义这个变量,但是要注意重定义等问题。

**9.Assertion index >= 0 && index < size()' failed. **
整个报错如下:
usr/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h:407: Eigen::DenseCoeffsBase<Derived, 1>::Scalar& Eigen::DenseCoeffsBase<Derived, 1>::operator()(Eigen::DenseCoeffsBase<Derived, 1>::Index) [with Derived = Eigen::Matrix<double, -0x00000000000000001, 1>, Eigen::DenseCoeffsBase<Derived, 1>::Scalar = double, Eigen::DenseCoeffsBase<Derived, 1>::Index = long int]: Assertion
index >= 0 && index < size()’ failed.
Aborted (core dumped)

是在使用eigen的时候没有进行初始化,需要指定向量x的大小。 如果像下面

Eigen::VectorXd x;

一样声明x,它将是一个空的向量(一个长度为0的向量),所以当你尝试访问它的第一个元素时,你会收到一个错误。

10. error: expected unqualified-id before ‘return’
return没有包含在在main函数中,很可能是{}括号不匹配,导致人return在main函数之外。

11./usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 10/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 11/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 10

缺失了main函数!检查拼写等问题。
未完待续…

参考博客列表:
http://blog.csdn.net/lele2426/article/details/12617369
https://forum.kde.org/viewtopic.php?f=74&t=107366
https://stackoverflow.com/questions/10766256/linker-returns-relocation-has-an-invalid-symbol-at-symbol-index

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值