arduino / arduino/ArduinoCore-avr

Add -fshort-enums

Open
#269 8 comments 0 reactions 1 assignee Claimed by @aentinger View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

It took me an extremely long time to debug a c code that used an uint8_t enum (that requires the 8 bit and not 16 bit size). The reason is that `-fshort-enums` is not used for arduino. We should add this to the c and cpp flags, as you cannot define the enum size for c as in c++. The cpp still needs this flag, so if you include the header from a c++ file those are also compiled correct.

FYI that is what i use to check now in my source:

``` c
// Check if opcode enums are 8bit, otherwise the code will compile wrong
#ifndef __cplusplus
_Static_assert ((sizeof(flash_opcode_t) == sizeof(uint8_t)),
"Please use -fshort-enums to compile this source");
#endif
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.