error: no matching function for call to 'std::exception:exception(const char[16])'

LZ在扒有些源代码的时候,会遇到如下的一个问题,就是源代码的作者是在windows下运行的,但是LZ的编译环境是ubuntu,所以在使用windows下编译通过的代码的时候,仍然会碰到各种各样的问题。
高博说过如果你Linux足够牛的时候,在考虑在Windows下进行一些开发编译,所以LZ还是乖乖的选择了Linux。
具体报错如下所示:

error: no matching function for call to 'std::exception:exception(const char[16])'

只要把代码修改成以下格式就行了

std::logic_error ex("XXXXX");
throw std::exception(ex);

然后你可能以为问题就解决了,然而下面的错误小伙伴们可能还会遇到:

error:expected class-name before '{' token {
std::logic_error is not a menber of 'std'

报这个错误的原因是:对应的头文件没有加(继承时不能忘记加基类的头文件)

#include <stdexcept>

感觉现在念书,重点应该不是自己掌握了多少的知识,而是如果遇到了一个问题怎么样解决这个问题,注重的是解决问题的能力吧O(∩_∩)O哈哈~
感谢百度和谷歌,还有很多大神的分享^_^,不然靠自己,速度不知道会慢多少倍!

error: no matching function for call to ‘usb_cam::UsbCam::start(const char*, usb_cam::utils::io_method_t&, std::string&, int&, int&, int&)’ 156 | m_image_height, m_framerate); | ^ In file included from /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:36: /home/luli/catkin_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:180:8: note: candidate: ‘void usb_cam::UsbCam::start()’ 180 | void start(); | ^~~~~ /home/luli/catkin_ws/src/usb_cam/include/usb_cam/usb_cam.hpp:180:8: note: candidate expects 0 arguments, 6 provided /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp: In member function ‘bool usb_cam::UsbCamNode::take_and_send_image(): /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:172:43: error: request for member ‘stamp’ in ‘* new_image’, which is of non-class type ‘char’ 172 | m_image.header.stamp.sec = new_image->stamp.tv_sec; | ^~~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:173:44: error: request for member ‘stamp’ in ‘* new_image’, which is of non-class type ‘char’ 173 | m_image.header.stamp.nsec = new_image->stamp.tv_nsec; | ^~~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:176:63: error: request for member ‘step’ in ‘* new_image’, which is of non-class type ‘char’ 176 | if (m_image.data.size() != static_cast<size_t>(new_image->step * new_image->height)) { | ^~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:176:81: error: request for member ‘height’ in ‘* new_image’, which is of non-class type ‘char’ 176 | mage.data.size() != static_cast<size_t>(new_image->step * new_image->height)) { | ^~~~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:177:34: error: request for member ‘width’ in ‘* new_image’, which is of non-class type ‘char’ 177 | m_image.width = new_image->width; | ^~~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:178:35: error: request for member ‘height’ in ‘* new_image’, which is of non-class type ‘char’ 178 | m_image.height = new_image->height; | ^~~~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:179:37: error: request for member ‘encoding’ in ‘* new_image’, which is of non-class type ‘char’ 179 | m_image.encoding = new_image->encoding; | ^~~~~~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:180:33: error: request for member ‘step’ in ‘* new_image’, which is of non-class type ‘char’ 180 | m_image.step = new_image->step; | ^~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:181:38: error: request for member ‘step’ in ‘* new_image’, which is of non-class type ‘char’ 181 | m_image.data.resize(new_image->step * new_image->height); | ^~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:181:56: error: request for member ‘height’ in ‘* new_image’, which is of non-class type ‘char’ 181 | m_image.data.resize(new_image->step * new_image->height); | ^~~~~~ /home/luli/catkin_ws/src/usb_cam/src/ros1/usb_cam_node.cpp:185:41: error: request for member ‘image’ in ‘* new_image’, which is of non-class type ‘char’ 185 | memcpy(&m_image.data[0], new_image->image, m_image.data.size()); | ^~~~~ make[2]: *** [CMakeFiles/usb_cam_node.dir/build.make:63:CMakeFiles/usb_cam_node.dir/src/ros1/usb_cam_node.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:739:CMakeFiles/usb_cam_node.dir/all] 错误 2 make: *** [Makefile:141:all] 错误 2
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值