Namespace Issue

6 posts / 0 new
Last post
Offline
Last seen: 7 years 1 month ago
Joined: 06/10/2014
Posts: 49
Namespace Issue

Hi,

I have been working with on a C++ project using RTI Connext professional. We are now trying to port our code to use the RTI DDS micro edition. We have several namespaces defined in our IDL (modules). In some IDL files we have duplicate type names but they are defined in different module names. We use the -namespace switch with rtiddsgen. We are unable to build the code because the linker reports "multiple definitions" for generated sequence functions.

For example we have 2 IDL files that define a struct "Timespec", each in their own namespace:

module report
{
  const long MED_STRING_LEN = 100;
  const long LONGLONG_STRING_LEN = 250;

  struct Timespec
  {
    long seconds;
    long nanoseconds;
  }; //@top-level false

  struct TrendReport
  {
    string<MED_STRING_LEN> report_id; //@key
    Timespec date_time;
    string<LONGLONG_STRING_LEN> report;
}; // @top-level true

module event
{
  const long MED_STRING_LEN = 100;
  typedef long INT32;
  typedef long TIME_T;

  struct Timespec
  {
    TIME_T seconds;
    INT32 nanoseconds;
  }; //@top-level false

  struct TrendEvent
  {
    string<MED_STRING_LEN> event_class; //@key
    string<MED_STRING_LEN> event_type;
    Timespec date_time;
    string<MED_STRING_LEN> name; //@key
  }; // @top-level true

};

The linker seems to report multiple definition errors for all of the "sequence" generated code. For example we get:

multiple definition of `TimespecSeq_initialize'

multiple definition of `TimespecSeq_finalize'

multiple definition of `TimespecSeq_get_maximum'

Has anyone else seen this or know of a way to work around this? I can change the IDL to remove duplicate type names but my understanding was that the namespace should be supported in micro edition.

Thanks,

Anne Fiore

 

 

Organization:
Offline
Last seen: 9 months 1 week ago
Joined: 11/19/2015
Posts: 21

Hello Anne,

Yes, Micro supports option -namespace when source code is generated.

What version of Micro are you using? We have fixed a bug in Micro 2.4.10 that might be causing this problem.

Also, what is the exact command line that you used to generated the code?

Thanks,

Francis.

Offline
Last seen: 7 years 1 month ago
Joined: 06/10/2014
Posts: 49

Hi Francis,

I'm using Micro version 2.4.8 and this command to generate code from IDL:

rtiddsgen -I {idl_dir_name} -namespace -micro -language C++ -replace -d (source_dir_name} {idl_file_name}

For now, I removed all duplicate types and can compile the generated code. 

I'll check about updating to 2.4.10.

Thank you,

Anne

Offline
Last seen: 9 months 1 week ago
Joined: 11/19/2015
Posts: 21

Hello Anne,

I have tested your IDL and with version 2.4.10 everything is working fine. Did you try?

Regards,

Francis.

Offline
Last seen: 7 years 1 month ago
Joined: 06/10/2014
Posts: 49

Hi Francis,

I did get a copy of 2.4.10 and tried rtiddsgen. I found that duplicate types in different namespaces will compile without error if they have the same fields keyed/not keyed. We have a few cases where we have same type names with different keyed fields.

For example we have a type called GuidTimespec defined in 2 different namespaces (modules) like this:

module ice
{
    struct GuidTimespec
    {
        OCTET seconds[4];
        // Number of seconds since 1970-01-01 00:00 UTC

        OCTET fraction[2];
         // Fractional seconds to 100-microsecond resolution
    }; //@top-level false
}

module expr
{
    struct GuidTimespec
    {
        // Number of seconds since 1970-01-01 00:00 UTC
        octet seconds[4]; //@key
        // Fractional seconds to 100-microsecond resolution
        octet fraction[2]; //@key
    }; //@top-level false
}

In the Plugin code that gets generated for the ice namespace there are #defines that are conflicting with the Plugin code that gets generated for the expr module.

icePlugin.h:

/* Unkeyed type key serialization equivalent to sample serialization */
#define GuidTimespec_cdr_serialize_key GuidTimespec_cdr_serialize
#define GuidTimespec_cdr_deserialize_key GuidTimespec_cdr_deserialize
#define GuidTimespec_get_serialized_key_max_size GuidTimespec_get_serialized_sample_max_size

This is the error I'm getting:

exprPlugin.cxx: In function ‘RTI_UINT32 expr::GuidTimespec_get_serialized_sample_max_size(NDDS_Type_Plugin*, RTI_UINT32, void*)’:
icePlugin.h:1013:54: error: redefinition of ‘RTI_UINT32 expr::GuidTimespec_get_serialized_sample_max_size(NDDS_Type_Plugin*, RTI_UINT32, void*)’
#define GuidTimespec_get_serialized_key_max_size GuidTimespec_get_serialized_sample_max_size

We have worked around this by renaming the type. 

Thanks for following up and please let me know if I'm misunderstanding the problem here.

Anne

 

Offline
Last seen: 9 months 1 week ago
Joined: 11/19/2015
Posts: 21

Hello Anne,

I have confirmed the problem. It is happening only when -namespace and -language C++ are used when generating code.

Thanks,

Francis.