rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

rclcpp fails to build with MSVC with the /permissive- flag on

Open AustinMooreResonantSciences opened this issue 3 years ago • 0 comments

Bug report

Required Info:

  • Operating System:
    • Windows 10
  • Installation type:
    • binaries
  • Version or commit hash:
    • humble
  • DDS implementation:
    • Fast-RTP
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Create a minimal ros2 project

with the following cpp file

#include "rclcpp/rclcpp.hpp"

int main() {
  return 0;
}

the follwing CMakeLists.txt

cmake_minimum_required(VERSION 3.18)
project(test1)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

add_executable(test1 test.cpp)

target_compile_options(test1 PUBLIC /permissive-)
ament_target_dependencies(test1 rclcpp)

ament_package()

the following package.xml

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>test1</name>
  <version>0.0.0</version>
  <description>NA</description>
  <maintainer email="[email protected]">austin.moore</maintainer>
  <license>Proprietary</license>

  <buildtool_depend>ament_cmake</buildtool_depend>
  <depend>rclcpp</depend>
  <depend>std_msgs</depend>
  
  <buildtool_depend>rosidl_default_generators</buildtool_depend>
  <exec_depend>rosidl_default_runtime</exec_depend>
  <member_of_group>rosidl_interface_packages</member_of_group>
  
  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

Expected behavior

Configure the cmake project and build correctly with MSVC C++ conformance flag on "/permissive-"

Actual behavior

Fails to build with the following error due to MSVC C++ conformance flag.

C:\ros2\ros2-windows\include\rclcpp\rclcpp/service.hpp(320): error C2039: 'type': is not a member of 'std'

Additional information

I believe this is due to some expected non standard conforming behavior in the template from the expanded macro RCLCPP_ERROR. I can get it to build when I pass /Zc:twoPhase- which re enables non standard conforming two-phase name lookup. This link contains some of Microsoft's docs on the /permissive- flag https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170

I came across this issue trying to build with Qt6 on windows. The Qt6 cmake target adds the /permissive- flag to the compile options. My current temporary fix is to add /Zc:twoPhase- to any target requiring rclcpp, but I'd like to understand why MSVC doesn't like the RCLCPP_ERROR macro.