Skip to content

Commit b3023b8

Browse files
authored
Merge pull request #752 from ros2/mergify/bp/humble/pr-750
Fix deprecation warnings for message constants (backport #750)
2 parents 81e9007 + 66e93dc commit b3023b8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

rosidl_generator_cpp/resource/msg__struct.hpp.em

+3
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,11 @@ template<typename ContainerAllocator>
367367
const @(MSG_TYPE_TO_CPP['wstring'])
368368
@(message.structure.namespaced_type.name)_<ContainerAllocator>::@(c.name) = u"@(escape_wstring(c.value))";
369369
@[ else ]@
370+
#if __cplusplus < 201703L
371+
// static constexpr member variable definitions are only needed in C++14 and below, deprecated in C++17
370372
template<typename ContainerAllocator>
371373
constexpr @(MSG_TYPE_TO_CPP[c.type.typename]) @(message.structure.namespaced_type.name)_<ContainerAllocator>::@(c.name);
374+
#endif // __cplusplus < 201703L
372375
@[ end if]@
373376
@[ if c.name in msvc_common_macros]@
374377
#if defined(_WIN32)

rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake

+5-4
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ if(rosidl_generate_interfaces_LIBRARY_NAME)
100100
endif()
101101
set_property(TARGET ${rosidl_generate_interfaces_TARGET}${_target_suffix}
102102
PROPERTY DEFINE_SYMBOL "ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_BUILDING_DLL")
103+
set_property(TARGET ${rosidl_generate_interfaces_TARGET}${_target_suffix}
104+
PROPERTY CXX_STANDARD 17)
105+
103106
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
104-
set_target_properties(${rosidl_generate_interfaces_TARGET}${_target_suffix} PROPERTIES
105-
CXX_STANDARD 17
106-
COMPILE_OPTIONS -Wall -Wextra -Wpedantic
107-
)
107+
target_compile_options(${rosidl_generate_interfaces_TARGET}${_target_suffix}
108+
PRIVATE -Wall -Wextra -Wpedantic)
108109
endif()
109110

110111
target_include_directories(${rosidl_generate_interfaces_TARGET}${_target_suffix}

0 commit comments

Comments
 (0)