amazon-freertos/lib/FreeRTOS-Plus-TCP/FreeRTOS_IP.c:1850:17: error: taking address of packed member of 'struct xUDP_HEADER' may result in an unaligned pointer value [-Werror=address-of-packed-member]
1850 | pusChecksum = ( uint16_t * ) ( &( pxProtPack->xUDPPacket.xUDPHeader.usChecksum ) );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this is very annoying. At the moment I am going to fix it using void pointers and the functions memcpy() and memset().
I ask you to analyze it and find the right way to do it.
The company I work for imposes the rule of using -Wall and -Werror. The MCUs I have the problem with are ARM Cortex-M4 and Cortex-M7.
I don’t think they can handle unaligned access.
Hello, I would go for the same option as proposed by @hs2.
FreeRTOS+TCP indeed uses packed structures in order to increase ease of coding and also performance.
E.g. you do not want to use a memcpy() to copy 4 bytes. A 32-bit assignment is much more efficient. All accesses of this type have been checked for their correctness.
Sorry, I’m just seeing this post. FreeRTOS+TCP has been thoroughly tested on both ARM Cortex-M4/M7. The access of data is never badly aligned: either 8, 16 or 32 bits.