IDL converts sequence<> to struct?

4 posts / 0 new
Last post
Offline
Last seen: 1 year 1 month ago
Joined: 03/25/2018
Posts: 10
IDL converts sequence<> to struct?

Hi,

 

I have a question of using sequence. I added in seqence in IDL, for example below:

struct myTestSequence_T {

double myFirstVar; //@key

seqence<long,10> mySeqLong;

};

After convertion to C using rtiddsgen, the sequence was translated to struct. See below. 

typedef struct myTestSequence_T{

CDR_double myFirstVar;

struct CDR_LongSeq seqLong;

} myTestSequence_T;

Why is that so? Why not vector<>?

Thank you so much.

CB

Offline
Last seen: 1 year 1 month ago
Joined: 03/25/2018
Posts: 10

Hi,

I found out the reason. My mistake. It was because I convert as C, and not C++, thus it won't be vector.

I need to figure out how to use sequence in C. If anyone can point me a way will be appreciated.

Thanks.

CB

Gerardo Pardo's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 06/02/2010
Posts: 589

Hi,

Here is a list of places where you can learn more about sequences in C.

The C API Reference contains a section on sequences.

The Examples available on this portal contains one on using sequences, see https://community.rti.com/examples/using-sequences. There you can find the syntax used in C and other languages.

You may also want to read this HowTo on sequences. It provides a good introduction to how they are implemented in C and traditional C++  (modern C++ uses std::vector and Java and C# also use native constructs). The HowTo examples are in C++ but the C implementation is the same and there is a one-to-one mapping between the C++ operations and the C functions. For example the C++ operation Foo::length() becomes Foo_length() for C.

Gerardo 

Offline
Last seen: 1 year 1 month ago
Joined: 03/25/2018
Posts: 10

Hi Gerardo, 

Thank you very much. Appreciate your help.

Chee Beng