From: Paul Eggert <eggert@cs.ucla.edu>
To: Bruno Haible <bruno@clisp.org>,
bug-gnulib@gnu.org, epsilon-devel@gnu.org
Cc: poke-devel@gnu.org
Subject: Re: Keep config.h idempotent
Date: Wed, 25 Jan 2023 14:00:21 -0800 [thread overview]
Message-ID: <66302311-fded-4403-525e-cfa2a9cfde64@cs.ucla.edu> (raw)
In-Reply-To: <2093695.QfOb2KXJ6Q@nimes>
On 2023-01-25 06:05, Bruno Haible wrote:
> What happens, is that this compilation unit #includes <config.h> five times,
> and somewhere between the first and the fifth inclusion, poke's code does
> #define returns_nonnull
>
> This is their particular way of not emitting this particular GCC/clang
> attribute, and is OK since 'returns_nonnull' is not a keyword and not a
> token in the reserved namespace.
Is this diagnosis correct? It appears to me that poke 2.90.1's "#define
returns_nonnull" is not a problem, because the Gnulib code never uses
that identifier. Instead, the Gnulib code does this:
#if _GL_HAS_ATTRIBUTE (returns_nonnull)
which uses this macro:
# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
and so has the same effect as this:
#if __has_attribute (__returns_nonnull__)
regardless of what returns_nonnull was defined to, because C doesn't
macro-expand immediate operands of ##.
If I understand things correctly the problem with poke 2.90.1 wasn't its
"#define returns_nonnull"; it was its "#define __returns_nonnull__",
which indeed defines a token in the reserved namespace.
> Hence this sequence
>
> #include <config.h>
> #define returns_nonnull
> #include <config.h>
>
> is supposed to work fine.
Isn't there still a problem with something like the following, even with
the latest Gnulib?
#define __returns_nonnull__
#include <config.h>
That is, it seems to me that the real problem here is a collision with
poke's "#define __returns_nonnull__" before <config.h>, not with
including <config.h> twice.
Obviously we can't make Gnulib immune to arbitrary #defines of reserved
names. This is not to say that we shouldn't accommodate GNU poke, just
that it's not clear that the cure is right here, as a general rule.
More generally, I don't think Gnulib should imply to users that it's OK
to include <config.h> twice. That's an uncommon practice and is a recipe
for trouble, as too many programs do fun stuff in their configure.ac
that Gnulib has no control over. Instead, we should clarify Gnulib's
documentation to say that compilation units should include <config.h>
first, before including anything else, and should not include <config.h>
later.
next prev parent reply other threads:[~2023-01-25 22:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 14:05 Keep config.h idempotent Bruno Haible
2023-01-25 22:00 ` Paul Eggert [this message]
2023-01-25 23:48 ` Bruno Haible
2023-01-26 4:17 ` Paul Eggert
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=66302311-fded-4403-525e-cfa2a9cfde64@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=epsilon-devel@gnu.org \
--cc=poke-devel@gnu.org \
/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).