We've used the RTI traditional C++ API before with linked libraries. Now we would like to use the "modern" C++11 API.
However, our applications are compiled with exceptions disabled (-fno-exceptions). This cases the compilation to fail:
In file included from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/rti/core/LocatorFilter.hpp:27, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/rti/core/policy/CorePolicy.hpp:40, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/dds/core/policy/detail/CorePolicy.hpp:26, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/dds/core/policy/CorePolicy.hpp:27, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/rti/domain/qos/DomainParticipantQosImpl.hpp:26, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/dds/domain/qos/detail/DomainParticipantQos.hpp:27, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/dds/domain/qos/DomainParticipantQos.hpp:26, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/dds/domain/TDomainParticipant.hpp:32, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/dds/domain/detail/DomainParticipant.hpp:26, from /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/dds/domain/DomainParticipant.hpp:26, from /home/user/archer/build/_deps/idl-build/idl/idl/version.hpp:24, from /home/user/archer/avionics_apps/apps/test_application/src/test_application.cpp:14: /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/rti/core/Locator.hpp: In member function ‘rti::core::Locator& rti::core::Locator::address(const ByteSeq&)’: /home/user/rti_connext_dds-6.0.1/include/ndds/hpp/rti/core/Locator.hpp:230:69: error: exception handling disabled, use ‘-fexceptions’ to enable 230 | throw dds::core::InvalidArgumentError("address too long"); | ^
- Is it even possible to use modern C++11 API with no exceptions?
- If it is, is there examples and documentation of that?
Thank you,
-Ilya.
Hi Ilya,
It's not possible.
The way the API is designed only makes sense when errors are reported through exceptions. Otherwise we wouldn't be able to extensively use constructors, assignment and move operators, value-type semantics, etc.
One of the reasons we still maintain the traditional C++ API is for use cases where exceptions are not allowed.
Alex
Hi Alex:
I understand. It is a bit sad though.
Which C++ API can I use with no exceptions?
What about rtiddsgen tool? I've used it with `-language c++` parameter and it generated code with expections.
For example, this is the code generated with `-language c++`
The same code with `-language C` looks this:
No exceptions even though it is calling the same underlined function RTICdrType_copyChar.
Thank you,
-Ilya.