cancel
Showing results for 
Search instead for 
Did you mean: 

Compilation Warning in STM32_WPAN package

AFink
Associate III

Hi,

I'm working with STM32_WPAN package (attached), on STM32CubeIDE (gcc compiler).

MCU: STM32WB55

There's a Compilation Warning that I don't know how to deal:

converting a packed 'TL_EvtPacket_t' pointer (alignment 1) to a 'tListNode' {aka 'struct _tListNode'} pointer (alignment 4) may result in an unaligned pointer value [-Waddress-of-packed-member].

Can you please help me fixing this Warning?

AFink_0-1706515676051.png

 

AFink_0-1706516168038.png

 

Thanks,

Aviv

2 REPLIES 2
tjaekel
Lead

Hi Aviv,
this warning is more likely a serious issue:

Is this code coming from a working project/repository?

What is this "PACKED_STRUCT"? This seems to cause the warning:

What does it tell me?:

  • you define "PACKED_STRUCTs":
    it means: a structure with members which are not really aligned with memory boundaries (e.g. every four bytes, a new pointer or int/long/ptr variable is not aligned), the final memory footprint could place members on unaligned memory start addresses
  • It could be just a "warning" that members are not aligned, but the code using these structures can be still correct (it depends how they use all the members of a struct - we have to see the other code using such variables)
  • And it can be, that it is the intention to create a "packed" structure but all the members are still properly accessed, e.g. as bytes, the code can be correct using it, just the definition is a warning that it could go wrong if using "without care".
  • compiler settings might have an option to ignore such "strict alignment" warnings:
    https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html   (see -Wcast-align=strict or -Wcast-align)

You might be able to disable alignment warnings. And I think you get it because your "packed" structs are really not aligned. But the code using it could be still OK (depends how the struct members are used at the end).

AFink
Associate III

Hi tjaekel,

thanks for your reply. 

Actually this code is from ST's STM32_WPAN package. So, I have no clue whether it handles the mis-alignment correctly (I'd like to believe it does...).

I was hoping that some ST guy can tell how to solve this Warning. I rather solving it rather than discarding the Warning in compiler.

 

Thanks,

Aviv