On 25/02/2023, 11:47, "Karel Kočí" <cyn...@email.cz <mailto:cyn...@email.cz>> wrote:
>I would use union (that is host ordering) and to convert to specific ordering >you can use functions like htobe32 (big endian) and htole32 (little endian), > those are available. > Excerpts from Tim Hardisty's message of February 25, 2023 11:26 am: >> As is so often the case, I need to pack an array of 4x uint8_t into a >> uint32_t. Obviously there are many ways to do this and we all have our >> favourite. For NuttX: >> >> 1) have I missed a library function that does this already? >> 2) to cope with big and little end is there a NuttX CONFIG or other >> parameter that will give the endian-ness of the arch being built to ensure >> the byte packing is done correctly? When using a union is it fair to assume that it is the responsibility of an app rather than a driver to sort endian-ness? I can find no references in the NuttX code base to changing endian-ness? Perhaps I'm over-thinking!