Fast-DDS-Gen icon indicating copy to clipboard operation
Fast-DDS-Gen copied to clipboard

Compile error when using -typeobject in fastddsgen

Open NeilTruter opened this issue 2 years ago • 5 comments

Is there an already existing issue for this?

  • [X] I have searched the existing issues

Expected behavior

Successful compile of code when specifying -typeobject when using fastddsgen

Current behavior

When specifying '-typeobject' for fastddsgen, and then compiling my project I receive the error below. Omitting '-typeobject' from fastddsgen my project compiles without error.

/usr/local/include/fastcdr/Cdr.h:1381: error: ambiguous overload for ‘operator==’ (operand types are ‘uint8_t’ {aka ‘unsigned char’} and ‘eprosima::fastcdr::Cdr::Endianness’) In file included from /home/user/Projects/Generic/Libs/Omnibus/generated/Alarm.cxx:31: /usr/local/include/fastcdr/Cdr.h: In member function ‘eprosima::fastcdr::Cdr& eprosima::fastcdr::Cdr::serialize(const std::vector&, eprosima::fastcdr::Cdr::Endianness)’: /usr/local/include/fastcdr/Cdr.h:1381:53: error: ambiguous overload for ‘operator==’ (operand types are ‘uint8_t’ {aka ‘unsigned char’} and ‘eprosima::fastcdr::Cdr::Endianness’) 1381 | m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness)); | ~~~~~~~~~~~~ ^~ ~~~~~~~~~~ | | | | | eprosima::fastcdr::Cdr::Endianness | uint8_t {aka unsigned char}

/usr/local/include/fastrtps/types/TypeObject.h:18: In file included from /usr/local/include/fastrtps/types/TypeObject.h:18, In file included from /usr/local/include/fastrtps/types/TypeObject.h:18, from /home/user/Projects/Generic/Libs/Omnibus/generated/AlarmTypeObject.h:26, from /home/user/Projects/Generic/Libs/Omnibus/generated/Alarm.cxx:30: /usr/local/include/fastrtps/types/TypesBase.h:251:1: note: candidate: ‘typename std::enable_if<(std::is_arithmetic<_Tp>::value || std::is_enum<_Tp>::value), bool>::type eprosima::fastrtps::types::operator==(T, const eprosima::fastrtps::types::ReturnCode_t&) [with T = eprosima::fastcdr::Cdr::Endianness; typename std::enable_if<(std::is_arithmetic<_Tp>::value || std::is_enum<_Tp>::value), bool>::type = bool]’ (reversed) 251 | operator ==( | ^~~~~~~~

/home/user/Projects/Generic/Libs/Omnibus/generated/Alarm.cxx:31: In file included from /home/user/Projects/Generic/Libs/Omnibus/generated/Alarm.cxx:31: In file included from /home/user/Projects/Generic/Libs/Omnibus/generated/Alarm.cxx:31: /usr/local/include/fastcdr/Cdr.h:1381:53: note: candidate: ‘operator==(int, int)’ (built-in) 1381 | m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness)); | ~~~~~~~~~~~~~^~~~~~~~~~~~~

Steps to reproduce

Use -typeobject with fastddsgen and compile the generated source into your own project.

Fast DDS version/commit

Latest, 2.9.1

Platform/Architecture

Windows 10 Visual Studio 2019, Other. Please specify in Additional context section.

Transport layer

Default configuration, UDPv4 & SHM

Additional context

Problem exists on both Windows 10 and Ubuntu 22.04.1 LTS. Using QtCreator to compile code.

XML configuration file

No response

Relevant log output

No response

Network traffic capture

No response

NeilTruter avatar Feb 20 '23 06:02 NeilTruter

Hello @NeilTruter

Thanks for the report.

Following the contributing guidelines, this issue has been moved to the Fast DD-Gen repository.

Please, try this and let us know if it does not allow you to compile either.

JesusPoderoso avatar Mar 09 '23 06:03 JesusPoderoso

I ran into this issue as well, it seems to be an issue when compiling with C++20, I setup a small demo here: https://github.com/tmayoff/eprosima-test/tree/endianness, added the FASTRTPS_DYN_LINK didn't seem to do anything

tmayoff avatar Mar 13 '23 14:03 tmayoff

Another note this seems to just be a problem when compiling with clang++, where as g++ looks fine

tmayoff avatar Mar 13 '23 18:03 tmayoff

Another note this seems to just be a problem when compiling with clang++, where as g++ looks fine

I have this problem on both Windows and Ubuntu using Qt and compiling with MSVC on Windows and gcc on Ubuntu

NeilTruter avatar Mar 14 '23 06:03 NeilTruter

I ran into this issue as well, it seems to be an issue when compiling with C++20, I setup a small demo here: https://github.com/tmayoff/eprosima-test/tree/endianness, added the FASTRTPS_DYN_LINK didn't seem to do anything

I did some testing now and experiencing the same. Switching from C++20 to C++17 my project compiles successfully, using C++20 I get the errors mentioned above. Adding FASTRTPS_DYN_LINK makes no difference. Our top-level project settings set C++ to 20 due to some components requiring it thus I can't move away from it.

NeilTruter avatar Mar 14 '23 09:03 NeilTruter