2018-03-28 11:53 AM
I decided to try out the new TrueStudio. Downloaded and installed it, and also updated STM32CubeMX to the latest, as well as all the latest firmware packages.
I then created a new Cube project for TrueStudio using the STM32L452 with a mix of HAL and LL.
When I compile the project (nothing added by me at this point) I get the following error:
dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
It is on this code, which comes from stm32l4xx_ll_spi.h that is in the L4 firmware repository (v1.11.0)
__STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
{ *((__IO uint16_t *)&SPIx->DR) = TxData;}I assume it's because the DR register is defined previously as a __IO uint32_t
I know that it's a warning and not an error, but I really like to fix whatever causes warnings and get compiles without warnings. So, why is this happening on a virgin project created by CubeMX? And what is the suggested way to deal with it?
2018-03-28 11:57 AM
This keeps being reported, the problem is that GNU/GCC is complaining about a valid casting construct. ie Hey something looks odd here, take a look to see if it describes what you want. And yes, it instructs it to do what we want without creating some unnamed union/structure which other compilers will reject.
2018-03-28 12:14 PM
Well, the message is from GCC - so nothing specific to ST.
The way to find out about GCC warnings is to stick the message into google; in particular, the bit in the square brackets:
[-Wstrict-aliasing]
which is telling you the command-line option which controls this warning.
Note: when Googling, you need to omit the hyphen - otherwise Google takes that to mean 'exclude this term from the search'
Thus:
2018-03-28 12:46 PM
https://community.st.com/0D50X00009XkeqJSAR
https://community.st.com/0D50X00009XkXPESA3https://community.st.com/0D50X00009XkWkESAV
https://community.st.com/0D50X00009XkdjRSAR