diff --git a/rclcpp/CMakeLists.txt b/rclcpp/CMakeLists.txt index 81db9a365d..dd2bc51434 100644 --- a/rclcpp/CMakeLists.txt +++ b/rclcpp/CMakeLists.txt @@ -23,7 +23,7 @@ if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual) + add_compile_options(-Wall -Wextra -Wconversion -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual) endif() set(${PROJECT_NAME}_SRCS diff --git a/rclcpp/src/rclcpp/node_interfaces/node_parameters.cpp b/rclcpp/src/rclcpp/node_interfaces/node_parameters.cpp index f5d0aa7e64..412fba46c5 100644 --- a/rclcpp/src/rclcpp/node_interfaces/node_parameters.cpp +++ b/rclcpp/src/rclcpp/node_interfaces/node_parameters.cpp @@ -159,7 +159,7 @@ __lockless_has_parameter( // see https://en.cppreference.com/w/cpp/types/numeric_limits/epsilon RCLCPP_LOCAL bool -__are_doubles_equal(double x, double y, size_t ulp = 100) +__are_doubles_equal(double x, double y, double ulp = 100.0) { return std::abs(x - y) <= std::numeric_limits::epsilon() * std::abs(x + y) * ulp; } diff --git a/rclcpp/src/rclcpp/node_options.cpp b/rclcpp/src/rclcpp/node_options.cpp index cac10e6685..43c401828f 100644 --- a/rclcpp/src/rclcpp/node_options.cpp +++ b/rclcpp/src/rclcpp/node_options.cpp @@ -338,7 +338,7 @@ NodeOptions::get_domain_id_from_env() const _dupenv_s(&ros_domain_id, &ros_domain_id_size, env_var); #endif if (ros_domain_id) { - uint32_t number = strtoul(ros_domain_id, NULL, 0); + uint32_t number = static_cast(strtoul(ros_domain_id, NULL, 0)); if (number == (std::numeric_limits::max)()) { #ifdef _WIN32 // free the ros_domain_id before throwing, if getenv was used on Windows diff --git a/rclcpp/test/rclcpp/executors/test_multi_threaded_executor.cpp b/rclcpp/test/rclcpp/executors/test_multi_threaded_executor.cpp index bfe2b25457..b6fd2c3fda 100644 --- a/rclcpp/test/rclcpp/executors/test_multi_threaded_executor.cpp +++ b/rclcpp/test/rclcpp/executors/test_multi_threaded_executor.cpp @@ -83,7 +83,7 @@ TEST_F(TestMultiThreadedExecutor, timer_over_take) { { std::lock_guard lock(last_mutex); - double diff = std::abs((now - last).nanoseconds()) / 1.0e9; + double diff = static_cast(std::abs((now - last).nanoseconds())) / 1.0e9; last = now; if (diff < PERIOD - TOLERANCE) { diff --git a/rclcpp/test/rclcpp/test_time.cpp b/rclcpp/test/rclcpp/test_time.cpp index 141064e13d..8df4b341d2 100644 --- a/rclcpp/test/rclcpp/test_time.cpp +++ b/rclcpp/test/rclcpp/test_time.cpp @@ -275,8 +275,8 @@ TEST(TestTime, overflow_detectors) { // 256 * 256 = 64K total loops, should be pretty fast on everything for (big_type_t y = min_val; y <= max_val; ++y) { for (big_type_t x = min_val; x <= max_val; ++x) { - const big_type_t sum = x + y; - const big_type_t diff = x - y; + const big_type_t sum = static_cast(x + y); + const big_type_t diff = static_cast(x - y); const bool add_will_overflow = rclcpp::add_will_overflow(test_type_t(x), test_type_t(y));