Connext Version: 7.2.0
rtiddsgen Version: 4.2.0
I have the following constants defined:
<const name="MAX_NUM_VALS" type="int16" value="372"/> <const name="NUM_OCTETS_BITMASK" type="int16" value="MAX_NUM_VALS >> 3 + 1"/>
ERROR com.rti.ndds.nddsgen.Main In member_337, NUM_OCTETS_BITMASK could not be resolved to an integer
<const name="MAX_NUM_VALS" type="int16" value="372"/> <const name="NUM_OCTETS_BITMASK" type="int16" value="(MAX_NUM_VALS) >> 3 + 1"/>
As a follow-up, I needed to add parentheses to change operator precedence, but the got an error:
The extra set of parentheses results in the following error:
Hi seairth,
I've done a quick test and this is working for me. I've called rtiddsgen like this:
rtiddsgen -language C++11 -example arm64Darwin20clang12.0 test.xml
and this snippet is generated:RTI_CONSTEXPR_OR_CONST_STRING int16_t NUM_OCTETS_BITMASK = (((MAX_NUM_VALS)) >> 3) + 1;
MAX_NUM_VALS
The issue is not with the <const> statement itself, it seems, but when the const is used in a struct:
with the following command:
generates the following error:
If I change NUM_OCTETS_BITMASK to
then I do not get an error.
As for the bit-shift, this also seems related to using the const in a struct. If I change NUM_OCTETS_BITMASK to:
I get the following error:
The usage of ">>" vs ">>" makes no difference. The additional parentheses are required for correct order of operations in C/C++, so are not optional. Removing the parentheses around MAX_NUM_VALS just results in getting the original error.
Edit: I apologize for the repeated edits, but the editor keeps changing some of the greater-than/less-than symbols into their character reference format, and I'm changing them back to accurately show what is in my file.
Hi seairth,
rtiddsgen does not resolve the constant value and is generated in the same way that is defined in the IDL/XML. Then, constant values defined as an expression cannot be used to defined the length of a sequence or any other value that expect an integer.
The rationale for not resolving the constant during the code generation are:
e.g.
A.idl
const A = 5;
B.idl
#include A.id
const B = A + 5
I understand why a const expression wouldn't be resolved to a value during coegen, but that's not my problem. I'm perfectly fine with the expression being kept as-is in the generated code. But I need rtiddsgen to actually generate the code without throwing an error for valid expressions. If the expression is not valid for some reason, please point that out.
I agree we may improve the code generator. I have created the ticket to allow the use of constant expression to define the size of arrays, sequences and strings.
The code for the ticket is [CODEGENII-2041]