Closed jphickey closed 2 years ago
Calling this a "bug" because space efficiency is one of the core requirements/expectations of this CF implementation, and this is not meeting that expectation. Plus, instantiating values from a header file is against most/all standards - it is not expected that simple inclusion of a header will cause extra memory to be allocated in the binary.
This was partially addressed by #137, in that the DECLARE_FIELDS are only used in a single source file now, but it is not an ideal way to do it.
Better fix for this can be combined with #65, moving the field definitions into the codec code should achieve both.
The FSW has a macro called "DECLARE_FIELD" which creates a constant at global scope:
https://github.com/nasa/CF/blob/7b99b91cd50a347f8553fc68ea3b074ff0672251/fsw/src/cf_field.h#L54-L55
The constant is scoped as "static" so it doesn't create a linker error, but it still creates a separate instance of this global variable for each time the header is included.
Confirmed by checking
cf.so
and observing that each of these 8 fields occur in the binary file 8 times:https://github.com/nasa/CF/blob/7b99b91cd50a347f8553fc68ea3b074ff0672251/fsw/src/cf_cfdp_pdu.h#L73-L80