Use of name idl as a module doesn't work

6 posts / 0 new
Last post
Offline
Last seen: 7 years 10 months ago
Joined: 02/26/2016
Posts: 5
Use of name idl as a module doesn't work

This:

module idl
{
 enum A { a, b, c };
};
module other
{
 struct s
 {
 idl::A myA;
 };
};

  

when compiled using 

rtiddsgen file.idl

results in:

INFO com.rti.ndds.nddsgen.Main Running rtiddsgen version 2.3.0, please wait ...
idl_as_module.idl line 10:12 no viable alternative at character ':'
ERROR com.rti.ndds.nddsgen.Main idl_as_module.idl line 10:9 member type 'dl::A' not found
ERROR com.rti.ndds.nddsgen.Main Fail: The file couldn't be parsed and the rawTree wasn't generated
INFO com.rti.ndds.nddsgen.Main Done (failures)

 

is "idl" a reserved word?

 

 

Organization:
jwillemsen's picture
Offline
Last seen: 3 years 4 months ago
Joined: 09/24/2013
Posts: 55

No, "idl" is not a reserved keyword but your IDL does have an error, you can't have A and a, our IDL compiler gives this error

ridlc i2.idl
IDL::ParseError: "a" clashed with "A".
    i2.idl: line 3, column 11

Offline
Last seen: 7 years 10 months ago
Joined: 02/26/2016
Posts: 5

changing { a, b, c } in my example to { x, y, z } produced the same result.

jwillemsen's picture
Offline
Last seen: 3 years 4 months ago
Joined: 09/24/2013
Posts: 55

It looks to be an issue in rtiddsgen, I would recommend to open a support issue with RTI to get their support team to have a look.

Offline
Last seen: 5 years 1 month ago
Joined: 09/04/2019
Posts: 1

Hi Paul,

 

Did you find a solution ? 

I'm currently in the same case. 

 

Thank you

 

[EDIT] The solution is to reprend the "idl" module name with an underscore '_'. 

Offline
Last seen: 3 months 1 week ago
Joined: 12/05/2019
Posts: 16

Hello,

For reference sake, I'm updating this community post. Apologies to anyone notified.
The information below is relevant for the Connext DDS 6.0.1 release.

This is a known issue tracked as CODEGENII-661, and has been previously documented in the Release Notes.
The workaround involves prepending an underscore, '_', to the module name.

This workaround should be sufficient given that identifiers with a single preceding underscore are to be treated as if they didn't contain said underscore.
For reference, see the the 7.2.3.2 Escaped Identifiers section of the IDL 4.2 reference. In particular, the following text:

As IDL evolves, new keywords that are added to the IDL language may inadvertently collide with identifiers used in existing IDL and programs that use that IDL. [...] To minimize the amount of work, users may lexically "escape" identifiers by prepending an underscore (_) to an identifier. This is a purely lexical convention that ONLY turns off keyword checking. The resulting identifier follows all the other rules for identifier processing. For example, the identifier _AnIdentifier is treated as if it were AnIdentifier.

However, for historical reasons, Code Generator behaviour regarding the above is opt-in and is enabled by use of the -enableEscapeChar command line flag.
Unfortunately, CODEGENII-1263 is an issue in Connext DDS 6.0.1 that affects the above behaviour for certain identifiers. This is being addressed in our next release.

Regards,
Alejandro