The FSW has a macro called "DECLARE_FIELD" which creates a constant at global scope:
|
#define DECLARE_FIELD(NAME, NBITS, SHIFT) \ |
|
static const CF_FIELD_FIELD NAME = {.shift = (SHIFT), .mask = ((1 << NBITS) - 1)}; |
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:
|
DECLARE_FIELD(PDU_HDR_FLAGS_VERSION, 3, 5) |
|
DECLARE_FIELD(PDU_HDR_FLAGS_TYPE, 1, 4) |
|
DECLARE_FIELD(PDU_HDR_FLAGS_DIR, 1, 3) |
|
DECLARE_FIELD(PDU_HDR_FLAGS_MODE, 1, 2) |
|
DECLARE_FIELD(PDU_HDR_FLAGS_CRC, 1, 1) |
|
DECLARE_FIELD(PDU_HDR_FLAGS_RESERVED, 1, 0) |
|
DECLARE_FIELD(PDU_LENGTHS_ENTITY, 3, 4) |
|
DECLARE_FIELD(PDU_LENGTHS_TRANSACTION_SEQUENCE, 3, 0) |
The FSW has a macro called "DECLARE_FIELD" which creates a constant at global scope:
CF/fsw/src/cf_field.h
Lines 54 to 55 in 7b99b91
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.soand observing that each of these 8 fields occur in the binary file 8 times:CF/fsw/src/cf_cfdp_pdu.h
Lines 73 to 80 in 7b99b91