bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: byteswap.h behavior


From: Paul Eggert
Subject: Re: byteswap.h behavior
Date: Sun, 12 May 2024 13:30:50 -0700
User-agent: Mozilla Thunderbird

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]