On 2024-05-12 12:47, Collin Funk wrote:
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 sense a bit of confusion here. Although POSIX allows <endian.h> symbols like be16toh to be macros, I don't see where it allows be16toh(X) to evaluate X more than once, so an expression like be16toh(i++) has well-defined behavior even though it has a side effect.
A few function-like macros, like getc, are explicitly allowed to evaluate their arguments more than once, but ordinarily function-like macros are supposed to act like their corresponding functions.