UMSATS / tsat-utilities-kit

A suite of pre-written utilities that can be used to streamline and standardize common operations across TSAT subsystems.
MIT License
2 stars 0 forks source link

Make Custom Enums Packed #2

Open Koloss0 opened 2 months ago

Koloss0 commented 2 months ago

Enums in C are forced to be ints. However, the custom ID types in can_command_list.h such as PowerLineID are meant to be a single byte in width. To rectify this, custom ID types should be typedef'd to uint8_t. The enum keys can become #defines instead.

Koloss0 commented 3 weeks ago

Update: an alternative fix is to make the enums packed with GCC attributes. E.g:

typedef enum __attribute__((packed)) {
    ZERO = 0,
    ONE,
} MyPackedEnum;