#43: FILE: test/test_timer.c:143: + static int init = 0;$ ERROR: do not initialise statics to 0
时间: 2024-03-29 21:40:09 浏览: 21
The error message is telling you not to initialize static variables to 0 explicitly. In C, static variables are implicitly initialized to 0, so there is no need to explicitly set them to 0.
To fix the error, you can simply remove the initialization of the static variable `init` to 0, and let the variable be implicitly initialized to 0. For example:
```
static int init;
```
This will ensure that the static variable is correctly initialized to 0, and avoid the error message.
相关问题
Building CXX object CMakeFiles/usb_cam.dir/src/usb_cam.cpp.o /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp: In static member function ‘static void usb_cam::UsbCam::frame_timer_callback(const ros::TimerEvent&)’: /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp:306:24: error: ‘make_unique’ is not a member of ‘std’ auto ci = std::make_unique<sensor_msgs::CameraInfo>(camera_info->getCameraInfo()); ^~~~~~~~~~~ /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp:306:24: note: suggested alternative: ‘__unique’ auto ci = std::make_unique<sensor_msgs::CameraInfo>(camera_info->getCameraInfo()); ^~~~~~~~~~~ __unique /home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp:306:59: error: expected primary-expression before ‘>’ token auto ci = std::make_unique<sensor_msgs::CameraInfo>(camera_info->getCameraInfo()); ^ CMakeFiles/usb_cam.dir/build.make:62: recipe for target 'CMakeFiles/usb_cam.dir/src/usb_cam.cpp.o' failed make[2]: *** [CMakeFiles/usb_cam.dir/src/usb_cam.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/usb_cam.dir/all' failed make[1]: *** [CMakeFiles/usb_cam.dir/all] Error 2 Makefile:140: recipe for target 'all' failed make: *** [all] Error 2
这是一个编译错误,它指出在文件`/home/q/catkin_ws/src/usb_cam/src/usb_cam.cpp`的第306行中,`std`命名空间中不存在`make_unique`,它建议使用`__unique`作为替代。
这通常是因为编译器版本较旧导致的问题。`make_unique`是C++11中引入的智能指针创建函数,因此您需要确保您使用的编译器支持C++11。
您可以尝试升级您的编译器版本,或者在编译选项中添加`-std=c++11`或更高版本的标志。如果您使用的是ROS,则可以在`CMakeLists.txt`文件中添加以下行来设置编译器标志:
```cmake
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
```
这将确保使用C++11的编译器选项来编译您的代码。
..\source\src\user_timer.c(5): error: #29: expected an expression
引用\[1\]中提到了一个编译错误,错误信息为"..\source\src\user_timer.c(5): error: #29: expected an expression"。这个错误通常是由于语法问题引起的。引用\[2\]中提到了解决这个错误的方法,可以检查报错位置的语法问题。另外,引用\[3\]中给出了一个可能导致这个错误的示例,其中定义了两个宏,可能存在语法问题。根据这些信息,建议检查..\source\src\user_timer.c文件中第5行的语法,确保没有语法错误导致了这个错误的出现。
#### 引用[.reference_title]
- *1* [STM32调试过程中出现的问题1:](https://blog.csdn.net/weixin_44403365/article/details/108195263)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [关于(error: #29: expected an expression) 的解决方法](https://blog.csdn.net/aya_tao/article/details/120726956)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [error:#28: expression must、error:#29: expected an和warning:#186-D: pointless comparison](https://blog.csdn.net/qiushui984620/article/details/128846804)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]