gcc 编译器[-Wreorder]问题

本文深入探讨了在使用GCC编译器时遇到的构造函数中成员变量初始化顺序错误警告的原因及解决方案。通过实例演示,帮助开发者理解构造函数初始化规则,并提供了解决此类警告的方法。

 warning: ‘XXXClass::XX’ will be initialized after [-Wreorder]


刚开始使用gcc编译器,出现以上warning。

度之,构造函数中成员变量初始化的顺序要与类声明中的变量顺序一致,否则出现如题告警

解决方法就是按照顺序进行初始化。

modules/perception/env/src/lib/common/fitter/bspline_segment.cpp:874:10: warning: unused variable ‘use_front_point’ [-Wunused-variable] 874 | bool use_front_point = false; | ^~~~~~~~~~~~~~~ (08:19:17) INFO: From Compiling modules/perception/env/src/lib/localmap_construction/lane_mapping.cpp: modules/perception/env/src/lib/localmap_construction/lane_mapping.cpp: In lambda function: modules/perception/env/src/lib/localmap_construction/lane_mapping.cpp:331:125: warning: comparison of integer expressions of different signedness: ‘const uint64_t’ {aka ‘const long unsigned int’} and ‘int’ [-Wsign-compare] 331 | while (std::find_if(detected_lms.begin(), detected_lms.end(), [&new_id](const BevLaneMarker &lm) { return lm.id == new_id; }) != | ~~~~~~^~~~~~~~~ (08:19:25) INFO: From Compiling modules/perception/env/src/lib/sd_navigation/EnvInfoProcessor.cpp: In file included from modules/perception/env/src/lib/sd_navigation/EnvInfoProcessor.cpp:1: modules/perception/env/src/lib/sd_navigation/EnvInfoProcessor.h: In constructor ‘cem::fusion::navigation::EnvInfoProcessor::EnvInfoProcessor()’: modules/perception/env/src/lib/sd_navigation/EnvInfoProcessor.h:107:10: warning: ‘cem::fusion::navigation::EnvInfoProcessor::last_on_highway_’ will be initialized after [-Wreorder] 107 | bool last_on_highway_ = false; | ^~~~~~~~~~~~~~~~ modules/perception/env/src/lib/sd_navigation/EnvInfoProcessor.h:103:10: warning: ‘bool cem::fusion::navigation::EnvInfoProcessor::is_accumulated_valid_’ [-Wreorder] 103 | bool is_accumulated_valid_; | ^~~~~~~~~~~~~~~~~~~~~ modules/perception/env/src/lib/sd_navigation/EnvInfoProcessor.cpp:11:1: warning: when initialized here [-Wreorder] 11 | EnvInfoProcessor::EnvInfoProcessor() | ^~~~~~~~~~~~~~~~ (08:22:00) ERROR: /apollo/modules/perception/env/BUILD:43:11: C++ compilation of rule '//modules/perception/env:local_map_component_lib' failed (Exit 1): crosstool_wrapper_driver_is_not_gcc failed: error executing command external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -MD -MF bazel-out/k8-opt/bin/modules/perception/env/_objs/local_map_component_lib/local_map_component.pic.d ... (remaining 299 argument(s) skipped) x86_64-linux-gnu-gcc-9: fatal error: Killed signal terminated program cc1plus compilation terminated. (08:22:01) INFO: Elapsed time: 318.993s, Critical Path: 271.58s (08:22:01) INFO: 428 processes: 24 internal, 404 local. (08:22:01) FAILED: Build did NOT complete successfully编译失败,什么原因
10-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值