McCode icon indicating copy to clipboard operation
McCode copied to clipboard

The component `_index` property is `long` but `_getcomp_index` returns `int`

Open g5t opened this issue 10 months ago • 1 comments

As seen in the code generator, the property of each component representing its position along the instrument is long valued https://github.com/McStasMcXtrace/McCode/blob/c4c9421d630767f612703947bad4c82941220398/mcstas/src/cogen.c.in#L542

The _getcomp_index function finds the component which has a user-provided name and returns an int valued index. https://github.com/McStasMcXtrace/McCode/blob/c4c9421d630767f612703947bad4c82941220398/mcstas/src/cogen.c.in#L1032

This type difference is unlikely to produce problems, but may be problematic on systems where int and long are not type aliases for the same underlying integer value type.

To alleviate any possible comparison errors, the component _index and return value for _getcomp_index should have the same type -- either int or long.

g5t avatar Apr 12 '24 15:04 g5t