On 5/12/24 12:38 PM, Paul Eggert wrote: >> Also if we can agree upon making sure these are defined as functions, >> what is the proper way to test it in a configure script? My instinct >> tells me that assigning a function pointer to bswap_16, etc. would >> fail if they are macros > > I don't see the need to check that they are functions. POSIX does not require > endian.h symbols like be16toh to be defined as functions, and the glibc > manual doesn't mention endian.h, so it sounds like Gnulib-using code > shouldn't assume that these symbols are functions.
Yeah, I read the POSIX draft and it says that they may be macros. I doubt the byteswap.h and endian.h functions are used with non-constant expression arguments that often. I worry though that in some cases programs will be accustomed to glibc's behavior. Since all of the functions are just macros to static inline functions in <bits/byteswap.h> arguments will only be evaluated once. It seems like it could be the cause of some unexpected bugs... Collin