You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to integrate ament_cmake_clang_tidy in my ROS2 Humble codebase, but I do not understand why it outputs errors about the libraries that I am using (i.e. rclcpp). Therefore, the test is failing but not because of my code. The following is a minimal example to reproduce the problem:
Steps:
follow the ros2 tutorial guide about minimal subscriber to create minimal workspace.
Build the system with colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
From your ROS2 workspace execute: ament_clang_tidy build/cpp_pubsub/
The output is:
found compilation database for package "cpp_pubsub"...
The invocation of "clang-tidy" failed with error code 1: Command '['/usr/bin/clang-tidy', '-p', 'build/cpp_pubsub', '--header-filter', 'include/cpp_pubsub/.*', '/home/niccolo-hiro/ros/nisa_robot_ws/src/cpp_pubsub/src/publisher_member_function.cpp']' returned non-zero exit status 1.
error: too many errors emitted, stopping now [clang-diagnostic-error]
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:550:10: error: no member named 'optional'in namespace 'std' [clang-diagnostic-error]
std::optional<CallbackInfoVariant>~~~~~^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:550:19: error: use of undeclared identifier 'CallbackInfoVariant' [clang-diagnostic-error]
std::optional<CallbackInfoVariant>
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:551:5: error: use of undeclared identifier 'optional_pending_request' [clang-diagnostic-error]
optional_pending_request = this->get_and_erase_pending_request(request_header->sequence_number);
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:552:10: error: use of undeclared identifier 'optional_pending_request' [clang-diagnostic-error]
if (!optional_pending_request) {
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:555:21: error: use of undeclared identifier 'optional_pending_request' [clang-diagnostic-error]
auto & value = *optional_pending_request;
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:558:14: error: no member named 'holds_alternative'in namespace 'std' [clang-diagnostic-error]
if (std::holds_alternative<Promise>(value)) {
~~~~~^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:558:32: error: unexpected type name 'Promise': expected expression [clang-diagnostic-error]
if (std::holds_alternative<Promise>(value)) {
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:561:21: error: no member named 'holds_alternative'in namespace 'std' [clang-diagnostic-error]
} elseif (std::holds_alternative<CallbackTypeValueVariant>(value)) {
~~~~~^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:561:39: error: unexpected type name 'CallbackTypeValueVariant': expected expression [clang-diagnostic-error]
} elseif (std::holds_alternative<CallbackTypeValueVariant>(value)) {
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:568:21: error: no member named 'holds_alternative'in namespace 'std' [clang-diagnostic-error]
} elseif (std::holds_alternative<CallbackWithRequestTypeValueVariant>(value)) {
~~~~~^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:568:39: error: unexpected type name 'CallbackWithRequestTypeValueVariant': expected expression [clang-diagnostic-error]
} elseif (std::holds_alternative<CallbackWithRequestTypeValueVariant>(value)) {
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:702:10: error: use of class template 'std::lock_guard' requires template arguments [clang-diagnostic-error]
std::lock_guard guard(pending_requests_mutex_);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_mutex.h:223:11: note: template is declared here
class lock_guard
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:749:10: error: use of class template 'std::lock_guard' requires template arguments [clang-diagnostic-error]
std::lock_guard guard(pending_requests_mutex_);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_mutex.h:223:11: note: template is declared here
class lock_guard
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:768:10: error: use of class template 'std::lock_guard' requires template arguments [clang-diagnostic-error]
std::lock_guard guard(pending_requests_mutex_);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_mutex.h:223:11: note: template is declared here
class lock_guard
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:788:36: error: no template named 'variant'in namespace 'std' [clang-diagnostic-error]
using CallbackInfoVariant = std::variant<~~~~~^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:794:52: error: unknown type name 'CallbackInfoVariant' [clang-diagnostic-error]
async_send_request_impl(const Request & request, CallbackInfoVariant value)
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:808:8: error: no template named 'optional'in namespace 'std' [clang-diagnostic-error]
std::optional<CallbackInfoVariant>~~~~~^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:808:17: error: use of undeclared identifier 'CallbackInfoVariant' [clang-diagnostic-error]
std::optional<CallbackInfoVariant>
^
/opt/ros/humble/include/rclcpp/rclcpp/client.hpp:830:7: error: use of undeclared identifier 'CallbackInfoVariant' [clang-diagnostic-error]
CallbackInfoVariant>>
which as you can see is all related to rclcpp.
Furthrmore, setting in package.xml:
issuing: colcon test --packages-select cpp_pubsub --event-handlers console_direct+ provides exactly the same output.
Am I using this tool incorrectly?
Let me know,
cheers,
Niccolo
The text was updated successfully, but these errors were encountered:
pucciland95
changed the title
ament_clang_tidy outputs sysyem header errors despite --system-header is false as defalt
ament_clang_tidy outputs sysyem header errors despite --system-header is false as default
Oct 1, 2024
Ok, I think I found the problem. The newer versions of rclcpp use c++17. Indeed, adding --extra-arg=-std=c++17 to the clang-tidy command returns only the problems in the provided files. The full command is:
Notice that I used clang-tidy and not ament_clang_tidysince the latter does not provide a way to specify such an argument. A solution has already been proposed in #452, but it has been waiting for more than a year.
I will close the issue since my problem has been fixed.
Hi,
I am trying to integrate
ament_cmake_clang_tidy
in my ROS2 Humble codebase, but I do not understand why it outputs errors about the libraries that I am using (i.e.rclcpp
). Therefore, the test is failing but not because of my code. The following is a minimal example to reproduce the problem:Steps:
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ament_clang_tidy build/cpp_pubsub/
The output is:
which as you can see is all related to
rclcpp
.Furthrmore, setting in package.xml:
and in
CMakeList.txt
:issuing:
colcon test --packages-select cpp_pubsub --event-handlers console_direct+
provides exactly the same output.Am I using this tool incorrectly?
Let me know,
cheers,
Niccolo
The text was updated successfully, but these errors were encountered: