Hi Collin, > IIRC in <stdbit.h> there is: > > #define __STDC_ENDIAN_LITTLE__ /* Unique constant */ > #define __STDC_ENDIAN_BIG__ /* Unique constant */ > #define __STDC_ENDIAN_NATIVE__ /* __STDC_ENDIAN_LITTLE__ or > __STDC_ENDIAN_BIG__ */
You can work on this, once Paul has created an 'stdbit' module with the 3 sets of functions, as mentioned in the other mail, I would say. > But, I think the next POSIX revision has <endian.h> like Glibc which I > prefer. Preference or not — both ISO C and POSIX are relevant for us. If ISO C has endianness macros in <stdbit.h> and POSIX has endianness macros in <endian.h>, we will implement both. > So these defines: > > #define LITTLE_ENDIAN /* Unique constant */ > #define BIG_ENDIAN /* Unique constant */ > #define BYTE_ORDER /* LITTLE_ENDIAN or BIG_ENDIAN */ > > plus functions or macros: > > uint16_t be16toh (uint16_t); > uint16_t htobe16 (uint16_t); > > I could try to work on that if it seems useful to anyone else. Indeed, I see that this is scheduled for inclusion in the next POSIX revision: https://www.austingroupbugs.net/view.php?id=162 It is useful to do this already now, before the next POSIX revision is official, because when it becomes official it will contain *many* new functionalities. (And this new functionality is unlikely to change. It's been sitting in the waiting line since 2011 (!).) Bruno