nasa / EdsLib

CCSDS SOIS Electronic Data Sheet Tool and Library
Apache License 2.0
31 stars 12 forks source link

Checksum-based struct names prevent C code from referring to struct directly #10

Closed jphickey closed 3 years ago

jphickey commented 3 years ago

The structure generator employs a de-duplication strategy based on the 64-bit checksum value. Essentially, two structures that have exactly the same fields in the same order, with the same types, and the same names, will be both typedef'ed to the same underlying struct type.

However, this pattern of creating different containers/structs that have the same content is sometimes leveraged in C code to intentionally create type-safe values that should not be interchanged. If they are in turn rendered as typedef's to the same struct, then this defeats the type safety that was intended.

Removing this de-duplication for the "struct" types solves the problem, and does not really have a down side since additional "struct" definitions do not translate into the final product - it can still be de-duplicated in the runtime DB, even if the C header has duplicate structs.

jphickey commented 3 years ago

Note there are also some aspects of CFS Caelum where it expected/assumed that the struct name is simply the typedef name with the _t suffix removed. The checksum-based names also broke that assumption.