My target is a STM32 MCU with a Cortex-M4.
I have downloaded the arm-none-eabi toolchain for Windows 10 (gcc-arm-none-eabi-8-2018-q4-major).
I am compiling using Makefile and Cygwin.
In my software I need to use packed structures but when I compile my source code I have this warning message:
warning: 'packed' attribute ignored [-Wattributes]
To be sure I tested the feature with this code
typedef __packed struct
The expected result is 5 but the output is 8.
I found that '__packed' is defined in "gcc-arm-none-eabi-8-2018\arm-none-eabi\include\sys".
I have included these paths to compile command:
Is the 'packed' attribute supported/working? Am I missing something or doing something wrong?
Obviously I found the solution just after posting the question.
As described in GNU GCC Documentation, the attribute should go after the struct's fields.
So moving the attribute after the closing curly brace like:
} __packed test_pack;
removed the warning and now the size is correct.
Hope this will help someone else.
View all questions in GNU Toolchain forum