CCCommon.cpp:44:72: error: format not a string literal and no format arguments

本文解决了在使用cocos2dx进行编译时遇到的CCCommon.cpp文件中的format-not-a-string-literal错误,并提供了具体的修改配置application.mk中APP_CFLAGS的方法。
今天使用cocos2dx的native_build.sh

编译出错:
CCCommon.cpp:44:72: error: format not a string literal and no format arguments [-Werror=format-security]

解决办法:
jni/application.mk
APP_CFLAGS += -Wno-error=format-security
/thread_app In file included from ThreadBase.cpp:2: ThreadBase.h: In instantiation of ‘static std::string ThreadBase::format(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’: ThreadBase.h:53:53: required from ‘void ThreadBase::log(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’ ThreadBase.cpp:60:17: required from here ThreadBase.h:62:16: warning: format not a string literal and no format arguments [-Wformat-security] 62 | sprintf(buffer, fmt.c_str(), args...); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TaskA.cpp: In member function ‘virtual void TaskA::run()’: TaskA.cpp:7:9: error: ‘this_thread’ has not been declared 7 | this_thread::sleep_for(1s); | ^~~~~~~~~~~ TaskA.cpp:7:32: error: unable to find numeric literal operator ‘operator""s’ 7 | this_thread::sleep_for(1s); | ^~ TaskA.cpp:7:32: note: use ‘-fext-numeric-literals’ to enable more built-in suffixes In file included from TaskA.h:2, from TaskA.cpp:1: ThreadBase.h: In instantiation of ‘static std::string ThreadBase::format(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’: ThreadBase.h:53:53: required from ‘void ThreadBase::log(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’ TaskA.cpp:6:12: required from here ThreadBase.h:62:16: warning: format not a string literal and no format arguments [-Wformat-security] 62 | sprintf(buffer, fmt.c_str(), args...); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TaskB.cpp: In member function ‘virtual void TaskB::run()’: TaskB.cpp:7:9: error: ‘this_thread’ has not been declared 7 | this_thread::sleep_for(500ms); | ^~~~~~~~~~~ TaskB.cpp:7:32: error: unable to find numeric literal operator ‘operator""ms’ 7 | this_thread::sleep_for(500ms); | ^~~~~ TaskB.cpp:7:32: note: use ‘-fext-numeric-literals’ to enable more built-in suffixes bash: ./thread_app: No such file or directory
07-25
In file included from ThreadBase.cpp:2: ThreadBase.h: In instantiation of ‘static std::string ThreadBase::format(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’: ThreadBase.h:54:53: required from ‘void ThreadBase::log(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’ ThreadBase.cpp:60:17: required from here ThreadBase.h:63:16: warning: format not a string literal and no format arguments [-Wformat-security] 63 | sprintf(buffer, fmt.c_str(), args...); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TaskA.cpp: In member function ‘virtual void TaskA::run()’: TaskA.cpp:11:9: error: ‘this_thread’ has not been declared 11 | this_thread::sleep_for(1s); | ^~~~~~~~~~~ In file included from TaskA.h:2, from TaskA.cpp:1: ThreadBase.h: In instantiation of ‘static std::string ThreadBase::format(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’: ThreadBase.h:54:53: required from ‘void ThreadBase::log(const string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]’ TaskA.cpp:10:12: required from here ThreadBase.h:63:16: warning: format not a string literal and no format arguments [-Wformat-security] 63 | sprintf(buffer, fmt.c_str(), args...); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TaskB.cpp: In member function ‘virtual void TaskB::run()’: TaskB.cpp:11:9: error: ‘this_thread’ has not been declared 11 | this_thread::sleep_for(500ms); | ^~~~~~~~~~~
07-25
In file included from /usr/include/gazebo-11/gazebo/common/common.hh:8, from /home/robot/catkin_ws/src/wpr_simulation/include/wpr_simulation/wpr_plugin.h:45, from /home/robot/catkin_ws/src/wpr_simulation/src/wpr_plugin.cpp:37: /usr/include/gazebo-11/gazebo/common/Battery.hh:25:10: fatal error: sdf/sdf.hh: 没有那个文件或目录 25 | #include "sdf/sdf.hh" | ^~~~~~~~~~~~ compilation terminated. make[2]: *** [wpr_simulation/CMakeFiles/wpr_plugin.dir/build.make:63:wpr_simulation/CMakeFiles/wpr_plugin.dir/src/wpr_plugin.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:3206:wpr_simulation/CMakeFiles/wpr_plugin.dir/all] 错误 2 make[1]: *** 正在等待未完成的任务.... In file included from /opt/ros/noetic/include/ros/ros.h:40, from /home/robot/catkin_ws/src/atr_pkg/src/ma_node.cpp:1: /home/robot/catkin_ws/src/atr_pkg/src/ma_node.cpp: In function ‘void chao_callback(std_msgs::String)’: /opt/ros/noetic/include/ros/console.h:351:176: warning: format not a string literal and no format arguments [-Wformat-security] 351 | el_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__) | ^ /opt/ros/noetic/include/ros/console.h:354:5: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER’ 354 | ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(NULL, __VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/ros/noetic/include/ros/console.h:390:7: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION’ 390 | ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/ros/noetic/include/ros/console.h:575:35: note: in expansion of macro ‘ROS_LOG_COND’ 575 | #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__) | ^~~~~~~~~~~~ /opt/ros/noetic/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’ 110 | #define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ^~~~~~~ /home/robot/catkin_ws/src/atr_pkg/src/ma_node.cpp:6:4: note: in expansion of macro ‘ROS_INFO’ 6 | ROS_INFO(msg.data.c_str()); | ^~~~~~~~ /home/robot/catkin_ws/src/atr_pkg/src/ma_node.cpp: In function ‘void yao_callback(std_msgs::String)’: /opt/ros/noetic/include/ros/console.h:351:176: warning: format not a string literal and no format arguments [-Wformat-security] 351 | el_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__) | ^ /opt/ros/noetic/include/ros/console.h:354:5: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER’ 354 | ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(NULL, __VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/ros/noetic/include/ros/console.h:390:7: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION’ 390 | ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/ros/noetic/include/ros/console.h:575:35: note: in expansion of macro ‘ROS_LOG_COND’ 575 | #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__) | ^~~~~~~~~~~~ /opt/ros/noetic/include/rosconsole/macros_generated.h:162:23: note: in expansion of macro ‘ROS_LOG’ 162 | #define ROS_WARN(...) ROS_LOG(::ros::console::levels::Warn, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ^~~~~~~ /home/robot/catkin_ws/src/atr_pkg/src/ma_node.cpp:11:3: note: in expansion of macro ‘ROS_WARN’ 11 | ROS_WARN(msg.data.c_str()); | ^~~~~~~~ [ 82%] Linking CXX executable /home/robot/catkin_ws/devel/lib/ssr_pkg/chao_node [ 82%] Built target chao_node [ 84%] Linking CXX executable /home/robot/catkin_ws/devel/lib/vel_pkg/vel_node [ 85%] Linking CXX executable /home/robot/catkin_ws/devel/lib/ssr_pkg/yao_node [ 87%] Linking CXX executable /home/robot/catkin_ws/devel/lib/atr_pkg/ma_node [ 87%] Built target yao_node [ 87%] Built target vel_node [ 87%] Built target ma_node [ 89%] Linking CXX executable /home/robot/catkin_ws/devel/lib/turtle_tf2/turtle_tf2_broadcaster [ 89%] Built target turtle_tf2_broadcaster [ 90%] Linking CXX executable /home/robot/catkin_ws/devel/lib/turtle_tf/turtle_tf_broadcaster [ 90%] Built target turtle_tf_broadcaster [ 92%] Linking CXX executable /home/robot/catkin_ws/devel/lib/turtle_tf/turtle_tf_listener_debug [ 93%] Linking CXX executable /home/robot/catkin_ws/devel/lib/turtle_tf2/turtle_tf2_listener [ 93%] Built target turtle_tf_listener_debug [ 93%] Built target turtle_tf2_listener [ 95%] Linking CXX executable /home/robot/catkin_ws/devel/lib/turtle_tf/turtle_tf_listener [ 95%] Built target turtle_tf_listener [ 96%] Linking CXX executable /home/robot/catkin_ws/devel/lib/turtle_tf/turtle_tf_message_filter [ 96%] Built target turtle_tf_message_filter [ 98%] Linking CXX executable /home/robot/catkin_ws/devel/lib/turtle_tf2/turtle_tf2_message_filter [ 98%] Built target turtle_tf2_message_filter make: *** [Makefile:141:all] 错误 2 Invoking "make -j16 -l16" failed
最新发布
09-08
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值