RTI Version 6.1.2, Code Generator 3.1.2
I'm doing a prebuild
CALL "$(NDDSHOME)\bin\rtiddsgen.bat" -ppDisable -inputIdl $(MSBuildProjectDirectory)\imported\Somefile.idl -language C# -d $(MSBuildProjectDirectory) -update typefiles
It generates code, but there are many errors in the code like the following
instrEventLogDeviceType = (Mantle.Datatypes.DeviceTypeEnum) -1;
Severity Code Description Project File Line Suppression State
Error CS0075 To cast a negative value, you must enclose the value in parentheses.
Am I missing a step or a rtiddsgen parameter?
Hello,
The error you are seeing is a known issue and had been addressed in the 7.1.0 version of rtiddsgen:
CODEGENII-1799 Negative enums need to be enclosed in parenthesis
Here are some details from our Connext ChatBot:
The error you are seeing:
instrEventLogDeviceType = (Mantle.Datatypes.DeviceTypeEnum) -1;
Severity Code Description Project File Line Suppression State Error CS0075 To cast a negative value, you must enclose the value in parentheses.
is a known C# compiler requirement: when casting a negative value to an enum, the negative value must be parenthesized, like this:
instrEventLogDeviceType = (Mantle.Datatypes.DeviceTypeEnum)(-1);
This is a limitation in the code generated by rtiddsgen for C# in RTI Connext 6.1.2 and Code Generator 3.1.2. The code generator does not add the required parentheses, which leads to this error.
You are not missing a step or a parameter; this is a known issue with the generated code for C# in this version. The workaround is to manually edit the generated code to add the parentheses where needed, or to use a later version of RTI Connext and Code Generator where this issue may be resolved.
There is no rtiddsgen parameter to change this behavior in 6.1.2. If you are able to upgrade to a newer version, this issue may be fixed in later releases.
If you must use 6.1.2, you will need to post-process the generated code or use a script to fix these lines automatically after code generation.
That works. Thank you for your help.