Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Custom Enums Packed #2

Open
Koloss0 opened this issue Apr 25, 2024 · 1 comment
Open

Make Custom Enums Packed #2

Koloss0 opened this issue Apr 25, 2024 · 1 comment
Labels
bug Something isn't working can wrapper good first task Good for newcomers

Comments

@Koloss0
Copy link
Collaborator

Koloss0 commented Apr 25, 2024

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 Koloss0 added the bug Something isn't working label Apr 25, 2024
@Koloss0 Koloss0 transferred this issue from another repository May 26, 2024
@Koloss0 Koloss0 added this to the MVP for FlatSat milestone Jun 16, 2024
@Koloss0
Copy link
Collaborator Author

Koloss0 commented Jun 23, 2024

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

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

@Koloss0 Koloss0 changed the title Use Typedefs instead of Enums for Custom ID Types Make Custom Enums Packed Jun 23, 2024
@Koloss0 Koloss0 added the good first task Good for newcomers label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working can wrapper good first task Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant