How do I convert a double type to a RTICdrLongLong type ?

Suppose you have a local variable in your application that is declared as a double (that is, a long long variable declared within an IDL file), and you try to cast it to a RTICdrLongLong variable, like this:

double doubleLocalVar = 0;

 /* Main loop */
for (count=0; (sample_count==0) || (count<sample_count); ++count) {
    /* setting test variables */
    doubleLocalVar += count; 
    instance->longLongIdlVar = (RTICdrLongLong) doubleLocalVar; 

The above code will cause the following errors:

No matching function for call to: 

Note: candidates are:
RTICdrLongLong::RTICdrLongLong(const RTICdrLongLong&)

To resolve the errors with the above code:

  1. Generate the architecture-specific makefile using rtiddsgen.
  2. Edit the generated makefile and modify the DEFINES_ARCH_SPECIFIC macro as follows:

Chapter 3 in the RTI Connext Core Libraries and Utilities User's Manual addresses this issue in Notes 1 and 2 for Tables 3.2 and 3.4 in Section 3.2.3 "rtiddsgen Translations for IDL Types". These notes also appear below:

Note 1: Note that in C and C++, primitive types are not represented as native language types (e.g., long, char, etc.) but as custom types in the DDS namespace (DDS_Long, DDS_Char, etc.). These typedefs are used to ensure that a field's size is the same across architectures and platforms.

Note 2. Some architectures do not support long long and long double, or have different sizes for those types than as defined by IDL (8 bytes for long long, 16 bytes for long double). In order for RTI Connext to treat types the same across all architectures, DDS_LongLong and DDS_LongDouble (as well as the unsigned versions) are mapped to character arrays that match the expected sizes of those types by default. If you are using an architecture whose native mappings have exactly the expected sizes, you can instruct RTI Connext to use the native types instead. That is, if sizeof(long long) == 8 and sizeof(long double) == 16, then you can tell RTI Connext to map DDS_LongLong to long long (or __int64 on Windows platforms) and DDS_LongDouble to long double by defining the following macros either in code or on the compile line:

Programming Language: