default size of enums

Asked by Pozz Pozz

I'm using arm-gcc from Atmel. It should be derived from "GNU Tools for ARM Embedded Processors".

I noticed enums with a small set of values are 1-byte variable. It seems -fshort-enums option is implicitly used. Why does it happen?
Isn't it dangerous when compiling with external libraries that were compiled without that option?

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Short answer: yes it is safe.

Previous version of the Procedure Call Standard for the ARM Architecture (also known as AAPCS) where stating explicitely that on bare metal target enum should be in the smallest container possible which corresponds to -fshort-enums by default for GCC. Newer versions of this document were reworded to state this in a separate document that is referenced from AAPCS. So yes it is safe as it is mandatory for bare metal target.

Best regards,

Thomas

Can you help with this problem?

Provide an answer of your own, or ask Pozz Pozz for more information if necessary.

To post a message you must log in.