I am trying to port some piece of code from OpenSplice to RTI and I have noticed that there are some modifications that I need to do to make it work. For example OpenSplice uses DomainParticipant_var type variable where RTI uses DomainParticipant* type variable. Is there any best practices or some other documentation that would show how to write as protable code as possible?
We have created some portable code between RTI and OpenDDS, and we solve the differences using a header file with some defines (I paste the code below). Perhaps you could follow a similar approach. I could create a GitHub Repo to maintain those header files if you provide yours.
#if defined(RTI_WIN32) || defined(RTI_LINUX)
#include "ndds_namespace_cpp.h"
#define PARTICIPANT_QOS_DEFAULT DDS_PARTICIPANT_QOS_DEFAULT
#define PUBLISHER_QOS_DEFAULT DDS_PUBLISHER_QOS_DEFAULT
#define TOPIC_QOS_DEFAULT DDS_TOPIC_QOS_DEFAULT
#define SUBSCRIBER_QOS_DEFAULT DDS_SUBSCRIBER_QOS_DEFAULT
#define STATUS_MASK_NONE DDS_STATUS_MASK_NONE
#define BOOLEAN_FALSE DDS_BOOLEAN_FALSE #define BOOLEAN_TRUE DDS_BOOLEAN_TRUE
#define strdup DDS_String_dup #define EPROSIMA_UINT32 RTI_UINT32
#elif defined(OPENDDS)
#include "dds/DdsDcpsC.h"
#include "dds/DdsDcpsInfrastructureC.h"
#include "dds/DCPS/Service_Participant.h"
#include "dds/DCPS/Marked_Default_Qos.h"
#include "dds/DCPS/GuardCondition.h"
#include "dds/DCPS/DataWriterImpl.h"
#define STATUS_MASK_NONE OpenDDS::DCPS::NO_STATUS_MASK
#define BOOLEAN_FALSE false
#define BOOLEAN_TRUE true
#define DDS_InstanceHandle_is_nil(ih) (ih == 0)
#define EPROSIMA_UINT32 ::CORBA::ULong
#endif
For the implementation of the CIAO DDS4CCM implementation we did use the RTI CCK together with the CCK to get the IDL to C++ language mapping defined types. This together with some wrappers and defines made it possible to at least write portable user code. For CIAO see http://download.dre.vanderbilt.edu.
For AXCIOMA we have taken the approach to use IDL to C++11 and hide all vendor details about a set of traits and typedefs, see https://www.axcioma.org for more about AXCIOMA.