-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set CXX standard to 17 #635
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather this used target_compile_features(target_name PUBLIC cxx_std_17)
instead, but I'd treat that as an enhancement rather than blocking this PR.
LGTM with green CI
CI
Jobs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! This looks good to me on a first pass, I think you missed one instance in rosidl_typesupport_introspection_cpp_generate_interfaces.cmake#L101
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_target_properties(${rosidl_generate_interfaces_TARGET}${_target_suffix} PROPERTIES
CXX_STANDARD 14
COMPILE_OPTIONS -Wall -Wextra -Wpedantic
)
The warnings in the MSVC build come from the deprecation of The deprecation message isn't benign because:
The suggestion here is not portable, being part of the Win32 API. The deprecation needs to be dealt with on all platforms regardless. There's a couple of ways to approach this:
|
Yes, that seems to be the modern approach to setting the C++ standard. Would also require upping the minimum cmake version to 3.10 in order to have support for MSVC. This is also a change that could be applied to all c++ packages.
Nice catch, I've pushed another commit that changes this one as well.
According to the deprecation statement, the codecvt "library component should be retired to Annex D, along side , until a suitable replacement is standardized" . I guess this means that it won't be removed for a long time. |
In the spirit of not fixing what isn't broken (yet!), I propose this deprecation be silenced with the if(MSVC)
ament_export_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
endif() |
Should I merge that branch into this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating! LGTM with green CI.
Rerunning CI from above:
- repos:
https://gist.githubusercontent.com/sloretz/6afda0358f48c644a0d292aae353e449/raw/e2f14016b0815e8c89af6233752f9a1cee1b8320/ros2.repos
- build:
--packages-up-to rosidl_runtime_c rosidl_runtime_c rosidl_typesupport_introspection_cpp rosidl_typesupport_interface rosidl_runtime_cpp rosidl_generator_cpp
- test:
--packages-select rosidl_runtime_c rosidl_runtime_c rosidl_typesupport_introspection_cpp rosidl_typesupport_interface rosidl_runtime_cpp rosidl_generator_cpp
Jobs
It looks like MSVC throws the deprecation warnings despite 7ec237e. I assumed the definition exporting mechanics would do the job. Any clues? May just have to define the silencing macro in the |
I don't think the 'ament_export_definitions' macro adds the preprocessor definition at all, it seems like it may have something to do with exporting definitions to downstream packages, but I can't find any documentation. For now, I think it's best to simply use add_compile_options (ROS hasn't begun to use the modern target-specific cmake style as far as I know). Not sure how this affects other packages that include this header, I'm not that familiar with the ament_cmake machinery (perhaps this is what ament_export_definitions does). Defining it in the header isn't a good option, as it needs to be defined before the STL libraries are pulled in (https://devblogs.microsoft.com/cppblog/c17-feature-removals-and-deprecations/). e.g. if (MSVC)
add_compile_options(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
endif()``` |
Every PR can be a small step in that direction! ;-)
Understood. Since if (MSVC)
target_compile_definitions(${PROJECT_NAME} INTERFACE
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
endif() |
The codecvt library is marked as deprecated in MSVC, but has no replacement in the standard. According to the deprecation notice, the library will not be removed until a suitable replacement has been standardized. In order to avoid pulling in additional third party libraries, the deprecation warning is disabled until the time comes that a replacement can be made (probably C++23) Signed-off-by: Øystein Sture <os@skarvtech.com>
Ok, I've added the proposed change and rebased/squashed the commits. Hopefully the current change successfully disables the warning on MSVC. |
Thanks for iterating @oysstu! There's a linter error in the CMakeLists.txt file, I think replacing |
Signed-off-by: Øystein Sture <os@skarvtech.com>
Rerunning CI:
Jobs |
@aprotyas @clalancette shall we get this moving? |
I think this PR is ready to go, feel free to merge it please! |
Test failures look unrelated. The windows test failure is reported as flaky. |
Indeed. Going in. Thanks @oysstu ! |
Set CXX standard to 17. Valid for Galactic and later (#634).