rtiddsgen error when enum is used

2 posts / 0 new
Last post
Joined: 09/06/2018
Posts: 16
rtiddsgen error when enum is used


We are trying to use our own defined type that uses an enum.  But, we are getting this java.langException when we attempt to run our IDL file with this content

struct State {

 enum foo { ZERO=0,ONE=1 } bar;


This IDL syntax appears to be okay wrt to OMG IDL spec grammar v4.2 in section  Is this syntax invalid for using an enum in an IDL file for use with rtiddsgen?  We ae using RTI DDS v5.3.1 on RHEL7.3.  The version of rtiddsgen in our RTI DDS installation is v2.5.2.





Fernando Garcia's picture
Joined: 05/18/2011
Posts: 187

Hi Bernardo,

From your example, I understand you are trying to declare an enum and then use it in the scope of a structure.

According to IDL v4.2, a structure is defined as follows:

(46) <struct_def> ::= "struct" <identifier> "{" <member>+ "}"
(47) <member> ::= <type_spec> <declarators> ";"

Every member is composed of a  <type_spec> and one or multiple <declarators>. If you go the definition of both, you will find the following:

(21) <type_spec> ::= <simple_type_spec>
(22) <simple_type_spec> ::= <base_type_spec>
                        | <scoped_name>

(67) <declarators> ::= <declarator> { "," <declarator> }*
(68) <declarator> ::= <simple_declarator>

That is, you may only refer to existing types (i.e., either simple built-in types --  <base_type_spec> or custom types declared outside the scope of the structure, identified by their <scope_name>), and name those members using a declarator (e.g., int a,b,c;).

Just for completion, an enum may only be declared as follows (out of the scope of a structure). Note that the braces that are not between quotes refer to optional comma-separeted enumerators you may append at the end of the enum declaration (e.g., BLUE, RED).

(57) <enum_dcl> ::= "enum" <identifier>
                    "{" <enumerator> { "," <enumerator> } * "}"
(58) <enumerator> ::= <identifier>

Therefore, to achieve what you intent, according to IDL v4.2 you must do the following:

enum Foo {

struct State {
    Foo bar;

Let me know if this solves your question.