This is a continuation of this question. We are using RTI version 6.0.1. Our base code has exceptions disabled with -fno-exceptions.
Is there a way to use any of the C++ APIs with no exceptions? I've tried all the different language options in rtiddsgen and except for C langiage all the generated code uses exceptions.
With `-langiage C++03` there is a an exception in <pre class="brush: bash">include/ndds/hpp/rti/core/LongDouble.hpp</pre> in the constructor.
// For internal use only
explicit LongDouble(double d) : NativeValueType<LongDouble>()
{
// This constructor exists to unify how the IDL-generated types treat
// long doubles in their default constructors regardless of if they
// are defined as this class or as the primtive type long double. They
// can always initialize it to zero by passing 0.0.
if (d != 0.0) {
throw dds::core::IllegalOperationError(
"LongDouble(double) constructor is for internal use only");
}
}
With `-language C++` there is a catch statemt in the <pre class="brush: cpp">type_copy</pre> method, even though the internal types are plain old simple and shouldn't be throwing anything.
RTIBool Version_copy( Version* dst, const Version* src)
{
try {
if (dst == NULL || src == NULL) {
return RTI_FALSE;
}
if (!RTICdrType_copyChar (
&dst->major, &src->major)) {
return RTI_FALSE;
}
if (!RTICdrType_copyChar (
&dst->minor, &src->minor)) {
return RTI_FALSE;
}
if (!RTICdrType_copyChar (
&dst->patch, &src->patch)) {
return RTI_FALSE;
}
if (!RTICdrType_copyUnsignedShort (
&dst->build_number, &src->build_number)) {
return RTI_FALSE;
}
return RTI_TRUE;
} catch (const std::bad_alloc&) {
return RTI_FALSE;
}
}
We used to use version 5.6.1 and this wasn't the problem.
Hi Ilya,
Starting in 5.3.0, the memory is allocated with constructors for Traditional C++ by default. Then, we need to catch bad allocation exceptions.
To avoid to generate code with try/catch you can use the flag -allocateWithMalloc in RTI Code Generator.
You will find more information in the section 5.2.26 Traditional C++ code could not be compiled with -fno-exceptions in the release notes fo RTI Code Generator.
https://community.rti.com/static/documentation/connext-dds/6.0.1/doc/manuals/connext_dds/code_generator/html_files/RTI_CodeGenerator_ReleaseNotes/index.htm#code_generator/ReleaseNotes/WhatsFixed/WhatsFixed300.htm?Highlight=codegenii-839
Jesus