bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Collin Funk <collin.funk1@gmail.com>
Cc: "bug-gnulib@gnu.org" <bug-gnulib@gnu.org>
Subject: Re: byteswap.h behavior
Date: Sun, 12 May 2024 13:30:50 -0700	[thread overview]
Message-ID: <46573ff0-0cd7-4d96-9f41-ec6c8a94ed89@cs.ucla.edu> (raw)
In-Reply-To: <bf40370e-abe5-4eb3-a6e6-dbfeaca7ad34@gmail.com>

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.


  parent reply	other threads:[~2024-05-12 20:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-12 19:23 byteswap.h behavior Collin Funk
2024-05-12 19:38 ` Paul Eggert
2024-05-12 19:47   ` Collin Funk
2024-05-12 20:02     ` Bruno Haible
2024-05-12 20:11       ` Collin Funk
2024-05-12 20:30     ` Paul Eggert [this message]
2024-05-12 22:43       ` Collin Funk
2024-05-12 23:10         ` endian.h Bruno Haible
2024-05-12 19:50 ` byteswap.h behavior Jeffrey Walton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46573ff0-0cd7-4d96-9f41-ec6c8a94ed89@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    --cc=collin.funk1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).