eProsima / Fast-DDS-Gen

Fast-DDS IDL code generator tool. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
82 stars 62 forks source link

Generating idl with -typeobject and including a header with typdefs causes c++ compilations errors. #163

Open tmayoff opened 1 year ago

tmayoff commented 1 year ago

We have an idl file that's used to define some typedefs that most if not all our other IDL files include. However when running fastddsgen with -typeobject (which I believe we need to be able to use Content Filtered Topics), we get this as the errors

FAILED: eprosima_test.p/meson-generated_.._TestTypeObject.cxx.o 
/usr/bin/g++ -Ieprosima_test.p -I. -I.. -I/usr/include -I/usr/include/foonathan_memory -I/usr/include/x86_64-linux-gnu/foonathan_memory -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c++17 -O0 -g -DFASTRTPS_DYN_LINK -DFOONATHAN_MEMORY=1 -DTINYXML2_IMPORT -MD -MQ eprosima_test.p/meson-generated_.._TestTypeObject.cxx.o -MF eprosima_test.p/meson-generated_.._TestTypeObject.cxx.o.d -o eprosima_test.p/meson-generated_.._TestTypeObject.cxx.o -c TestTypeObject.cxx
In file included from TestTypeObject.cxx:28:
TestTypeObject.h:58:47: error: default argument given for parameter 1 of ‘const eprosima::fastrtps::types::TypeIdentifier* GetMACHINEIDIdentifier(bool)’ [-fpermissive]
   58 | eProsima_user_DllExport const TypeIdentifier* GetMACHINEIDIdentifier(bool complete = false);
      |                                               ^~~~~~~~~~~~~~~~~~~~~~
In file included from TestTypeObject.h:25:
TestIncludeTypeObject.h:57:47: note: previous specification in ‘const eprosima::fastrtps::types::TypeIdentifier* GetMACHINEIDIdentifier(bool)’ here
   57 | eProsima_user_DllExport const TypeIdentifier* GetMACHINEIDIdentifier(bool complete = false);
      |                                               ^~~~~~~~~~~~~~~~~~~~~~
TestTypeObject.h:59:43: error: default argument given for parameter 1 of ‘const eprosima::fastrtps::types::TypeObject* GetMACHINEIDObject(bool)’ [-fpermissive]
   59 | eProsima_user_DllExport const TypeObject* GetMACHINEIDObject(bool complete = false);
      |                                           ^~~~~~~~~~~~~~~~~~
TestIncludeTypeObject.h:58:43: note: previous specification in ‘const eprosima::fastrtps::types::TypeObject* GetMACHINEIDObject(bool)’ here
   58 | eProsima_user_DllExport const TypeObject* GetMACHINEIDObject(bool complete = false);
      |                                           ^~~~~~~~~~~~~~~~~~
[5/6] Compiling C++ object eprosima_test.p/meson-generated_.._TestPubSubTypes.cxx.o
ninja: build stopped: subcommand failed.

A solution around this is to place the typedefs in an IDL module, but it would be nice to not need to do that.

A test project can be found here: https://github.com/tmayoff/eprosima-test

MRicoIE2CS commented 1 year ago

Hi @tmayoff, I have been able to reproduce your issue. When trying to compile the files generated using -typeobject flag, the compiles throws the lines stated in the issue. It happens with an idl including another idl which have a typedef. We will try to assign resources to resolve this issue. Thank you for the report.