Hi 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.
K.K. 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? > > Thx, TimH. > >
pgpql9kuxbWMq.pgp
Description: PGP signature