写宏遇到的问题:warning: backslash and newline separated by space - C

本文介绍了一种使用C预处理宏进行调试的方法,并通过一个具体示例展示了如何利用宏输出文件名、行号及函数名等信息,帮助开发者快速定位问题。

http://blog.youkuaiyun.com/liyongming1982/article/details/6663031

原来是因为\ 后面多了一个空格

   附上一个刚刚写得调试用的例子:

[cpp]  view plain copy
  1. #define desay_debug(_string,myValue) \  
  2.     do{\  
  3.          c_snprintf(desay_info, \  
  4.                   250 - 1, \  
  5.                   "\ndesay: File: %s  Line#: %d  Func: %s()\n !!!:message is %s value is %d\n", \  
  6.                   __FILE__, \  
  7.                   __LINE__, \  
  8.                   __func__, \  
  9.                   _string, \  
  10.                   myValue); \  
  11.         desayEvent.ui4_msg_id=DESAY_MESSAGE_ID;\  
  12.         desayEvent.ui4_data1=(UINT32)&desay_info[0];\  
  13.         a_am_get_app_handle_from_name(&h_app_desay,"homepage");\  
  14.         c_app_send_msg(h_app_desay,0,&desayEvent,sizeof(DESAY_MSG_T),NULL,NULL);\  
  15.     }while(0)  
改为GCC11,然后cmakelists文件也修改了,但是还是报错:In file included from /home/guo/定位新代码/src/share/common/include/base/file.h:15, from /home/guo/定位新代码/src/share/common/include/base/file.cpp:1: /home/guo/定位新代码/src/share/common/include/base/macros.h:29:62: warning: backslash and newline separated by space 29 | expression; \ | In file included from /home/guo/定位新代码/src/share/common/include/base/file.h:15, from /home/guo/定位新代码/src/share/common/include/base/format.h:13, from /home/guo/定位新代码/src/share/common/include/base/format.cpp:1: /home/guo/定位新代码/src/share/common/include/base/macros.h:29:62: warning: backslash and newline separated by space 29 | expression; \ | [ 96%] Linking CXX shared library /home/guo/定位新代码/devel/lib/libabsl_log_flags.so [ 96%] Built target log_flags In file included from /home/guo/定位新代码/src/share/common/include/base/health_reporter.h:13, from /home/guo/定位新代码/src/share/common/include/base/health_reporter.cpp:1: /home/guo/定位新代码/src/share/common/include/base/macros.h:29:62: warning: backslash and newline separated by space 29 | expression; \ | [ 96%] Linking CXX shared library /home/guo/定位新代码/devel/lib/libabsl_flags_usage_internal.so In file included from /home/guo/定位新代码/src/share/common/include/base/health_reporter.h:15, from /home/guo/定位新代码/src/share/common/include/base/health_reporter.cpp:1: /home/guo/定位新代码/src/share/common/include/base/traits.h:3:10: fatal error: concepts: 没有那个文件或目录 3 | #include <concepts> | ^~~~~~~~~~ compilation terminated. make[2]: *** [share/common/include/base/CMakeFiles/common_base.dir/build.make:104:share/common/include/base/CMakeFiles/common_base.dir/health_reporter.cpp.o] 错误 1 make[2]: *** 正在等待未完成的任务.... [ 96%] Built target flags_usage_internal Consolidate compiler generated dependencies of target flags_usage [ 97%] Building CXX object share/common/include/abseil-cpp/absl/flags/CMakeFiles/flags_usage.dir/usage.cc.o In file included from /home/guo/定位新代码/src/share/common/include/base/node_base.h:17, from /home/guo/定位新代码/src/share/common/include/base/node_base.cpp:1: /home/guo/定位新代码/src/share/common/include/base/macros.h:29:62: warning: backslash and newline separated by space 29 | expression; \ | In file included from /home/guo/定位新代码/src/share/common/include/base/node_base.h:19, from /home/guo/定位新代码/src/share/common/include/base/node_base.cpp:1: /home/guo/定位新代码/src/share/common/include/base/traits.h:3:10: fatal error: concepts: 没有那个文件或目录 3 | #include <concepts>
10-15
config/pallet_detect_class.h:23, from /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc:12: /home/workspace/hangcha_visual_program/visual/include/config/lsingleton.h:40:34: warning: backslash and newline separated by space 40 | #define GET_LSingObj(class_name) \ | /home/workspace/hangcha_visual_program/visual/include/config/lsingleton.h:42:38: warning: backslash and newline separated by space 42 | #define DESTROY_LSingObj(class_name) \ | /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc:17:6: error: no declaration matches 'bool Visual::PalletDetect::InitPalletDetectParam(std::string)' 17 | bool PalletDetect::InitPalletDetectParam(std::string yaml_dir){ | ^~~~~~~~~~~~ In file included from /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc:12: /home/workspace/hangcha_visual_program/visual/include/config/pallet_detect_class.h:36:14: note: candidate is: 'template<class PointT> bool Visual::PalletDetect::InitPalletDetectParam(std::string)' 36 | bool InitPalletDetectParam(std::string yaml_dir); | ^~~~~~~~~~~~~~~~~~~~~ /home/workspace/hangcha_visual_program/visual/include/config/pallet_detect_class.h:30:11: note: 'class Visual::PalletDetect' defined here 30 | class PalletDetect{ | ^~~~~~~~~~~~ /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc: In member function 'void Visual::PalletDetect::PassThrough(const pcl::PointCloud<pcl::PointXYZ>&, pcl::PointCloud<pcl::PointXYZ>&, std::string&, float&, float&, bool)': /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc:375:48: warning: 'void pcl::PassThrough<PointT>::setFilterLimitsNegative(bool) [with PointT = pcl::PointXYZ]' is deprecated: use inherited FilterIndices::setNegative() instead (It will be removed in PCL 1.13) [-Wdeprecated-declarations] 375 | pass.setFilterLimitsNegative(limit_negative); | ^ In file included from /home/workspace/hangcha_visual_program/visual/include/visual/pcl_common.h:19, from /home/workspace/hangcha_visual_program/visual/include/config/pallet_detect_class.h:14, from /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc:12: /home/workspace/hangcha_visual_program/library/pcl1_12/include/pcl-1.12/pcl/filters/passthrough.h:156:7: note: declared here 156 | setFilterLimitsNegative (const bool limit_negative) | ^~~~~~~~~~~~~~~~~~~~~~~ /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc: In member function 'bool Visual::PalletDetect::GetClusters(const pcl::PointCloud<pcl::PointXYZ>&, const std::vector<pcl::PointIndices>&, std::vector<clusterOBBICP>&)': /home/workspace/hangcha_visual_program/visual/src/Auto/pallet_detect.cc:687:1: warning: no return statement in function returning non-void [-Wreturn-type] 687 | } | ^ make[2]: *** [CMakeFiles/visual.dir/build.make:271: CMakeFiles/visual.dir/src/Auto/pallet_detect.cc.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:125: CMakeFiles/visual.dir/all] Error 2 make: *** [Makefile:130: all] Error 2
最新发布
11-15
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值