首页 >> 大全

C++ bug解决经验(一)

2023-08-24 大全 24 作者:考证青年

C++ bug解决经验(一) 1 error: ‘’

仔细检查下,头文件定义函数时未添加分号,或者函数未写完就编译了。

2 ‘’ was in this

原因:结构体没有定义别名

解决:曲调或者在结构体括号外添加别名

typedef struct Vehicle
{std::string name;					
}Veh;  // veh就是别名

3 坐标转换之后的角度,为什么只能按照固定轴序旋转

因为其实按照XYZ或者ZYX理论上都是可行的,只不过不同顺序所旋转的角度不一样,所以在计算的时候,我们会设定一种旋转方式,然后列出方程,最后解算的角度,当然要按照设定的顺序旋转了。

4 error: -id ‘if’

 error: expected unqualified-id before ‘if’

原始代码:

bool Swap(std::vector& left, std::vector& right, int dimension, double distance /* = 0.1 */)
{if (dimension >= left.size() || dimension >= right.size())return false;}// if下面划线,报错if (fabs(left[dimension] - right[dimension]) > distance) {/* code */}if (fabs(left[dimension] - right[dimension]) > distance) {Swap(left, right);return true;}
}

解决:

第一个if花括号不完整,补齐即可。

5 c++使用eigen提示"fatal error: Eigen/Dense: No such file or "的解决办法

源代码里面使用了

#include 

查看自己电脑,eigen的安装路径为:

/usr/include/eigen3/Eigen

解决办法:

(1)修改头文件为

#include 

(2) 复制/usr///Eigen中的文件到/usr//Eigen,可使用命令:

cp -rf /usr/include/eigen3/Eigen /usr/include/Eigen -R

6 Eigen报错:Eigen::::()

nlopt: /usr/include/eigen3/Eigen/src/Core/CommaInitializer.h:120: XprType& Eigen::CommaInitializer::finished() [with XprType = Eigen::Matrix]: Assertion `((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0) && m_col == m_xpr.cols() && "Too few coefficients passed to comma initializer (operator<<)"' failed.
Aborted (core dumped)

我的输入:

    Eigen::Vector4d point1, point2, point3, point4, point5, point6, point7;point1 << 5.45708, 5.1764, -0.5597;data_cp.point_array_1.push_back(point1);                 //右 rightpoint2 << 5.950488090515, 4.565999984741, -0.558037996292;point3 << 5.617546558380, 2.353021621704, -0.558990061283;point4 << 4.072897911072, 1.896781682968, -0.564294576645;point5 << 3.155550241470, 1.227772474289, -0.567389249802;point6 << 6.464124202728, -2.563307285309, -0.575628519058;point7 << 9.175043106079, -2.056616067886, -0.566318452358;

解决办法

重点在报错最后一句 "Too few to comma (

关于我们

最火推荐

小编推荐

联系我们


版权声明:本站内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 88@qq.com 举报,一经查实,本站将立刻删除。备案号:桂ICP备2021009421号
Powered By Z-BlogPHP.
复制成功
微信号:
我知道了