Hi,
Due to some reasons, I need to have the enum value start with -1.
But, this is giving me compilation errors this way:
/vobs/product-soup/common/dds/rti-dds/5.0.0/x64Linux/ndds.5.0.0/scripts/rtiddsgen -language C++ -replace -namespace -d . MyIdl.idl
Running rtiddsgen version 5.0.0.12, please wait ...
MyIdl.idl:20:19:unexpected token: -
Done (failures)
Line #20 in my IDL is where I defined by negative enum value:
VALUE_NONE = -1
Is there a way to overcome this compilation error?
Uday
Hello Uday,
IDL union do not support negative values. In fact in classic OMG IDL itself the values cannot be specified. The assignment of explicit values is an RTI extension, which has been incorporated into the just released OMG IDL 4.0 specifiation.
However negative values would break some of the language mappings. In Java, for example, negative integers are not supported. So for this reason the enumerated values are currently restricted to being non-nengative ints.
As an alternative you can define a set of constants and put them into a module. For example you could define the IDL like this:
Then in your code if you have an object of type Foo. You can set the value as follows:
Which has reasonable syntax in C++. In C This would be mapped to something like:
-Gerardo