eProsima / Fast-DDS-Gen

Fast-DDS IDL code generator tool. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
77 stars 59 forks source link

How to define enumeration with int value in IDL? #218

Closed Octavian-Zhang closed 10 months ago

Octavian-Zhang commented 10 months ago

Is it possible to define an enumeration as the following in IDL?

enum Enumeration : int32 
{
    RED = 1,
    GREEN = 2,
    BLUE = 3
};

If yes, what's the correct syntax for such a definition? The code snippet above isn't valid in IDL.

JLBuenoLopez commented 10 months ago

@Octavian-Zhang

The IDL to C++11 language mapping specification states in clause 6.9 that an IDL enumeration should map to an uint32_t C++11 enumeration. The DDS XTypes specification allows to modify the size of the enumerated type using the @bit_bound builtin annotation (Fast DDS-Gen does not support yet this specific annotation for enumerations, as stated in Fast DDS documentation). It does not seem to be a manner to define negative values within an IDL enumeration.