This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

'Packed' attribute support for STM32F4 (Cortex-M4)

Hi.

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
{
	uint8_t field1;
	uint32_t field2;
} test_pack;

int main(void)
{
  test_pack t1;
  
  printf("%d", sizeof(t1));
  
  return 0;
}

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:

gcc-arm-none-eabi-8-2018/arm-none-eabi/include
gcc-arm-none-eabi-8-2018/lib/gcc/arm-none-eabi/8.2.1/include
gcc-arm-none-eabi-8-2018/lib/gcc/arm-none-eabi/8.2.1/include-fixed

Is the 'packed' attribute supported/working? Am I missing something or doing something wrong?

Thanks.