Inadvertently embiggening a typedef'd array

2 posts / 0 new
Last post
Offline
Last seen: 11 years 4 months ago
Joined: 08/19/2013
Posts: 1
Inadvertently embiggening a typedef'd array

I have no doubt that seasoned RTI/DDS developers will spot the flaw in the following, but it's escaping me.

Given the following IDL input (call it Z.idl):

typedef struct Q
{
    long A[2];
    double B[3];
    char C[5];
} Q_t;

Compile it (using the RTI Connext 5.0.0 IDL compiler) and examine the resulting Q_t typedef:

mkdir -p temp
rtiddsgen.bat -inputIdl -ppDisable -replace -language C++ -d temp Z.idl
grep Q_t temp/Z.h | grep typedef

This produces the following surprising result for me:

typedef Q  Q_t[2][3][5];

The only workaround I've found is introducing N typedefs (one for each data member that is an array):

typedef long A_t[2];
typedef long B_t[3];
typedef long C_t[5];

typedef struct Q
{
    A_t A;
    B_t B;
    C_t C;
} Q_t;

Is there a way to phrase a data type containing N arrays without having to also write N array typedefs?

Thanks in advance...

Keywords:
Offline
Last seen: 4 years 6 months ago
Joined: 09/10/2010
Posts: 32

Hello,

      My name is Bert Farabaugh and I am a Field Applications Engineer at RTI.  With regard to your question of using Typedef's with a Struct, please try the following idl changes.

struct Q
{
   long A[2];
   double B[3];
   char C[5];
};

typedef Q Q_t;

Please contact me if you have any additional questions.

bertf@rti.com