public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Zack Weinberg <zackw@panix.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	Vivek Das Mohapatra <vivek@collabora.com>
Subject: Re: #pragma once usage
Date: Fri, 26 Feb 2021 16:09:45 -0500	[thread overview]
Message-ID: <CAKCAbMhggO3cs6KqWPTSBotAcG=B0MEC5dUEc9fMK=JfNd4VKA@mail.gmail.com> (raw)
In-Reply-To: <0d9eceac-986e-2944-8c5e-bf25063229ad@linaro.org>

On Fri, Feb 26, 2021 at 2:10 PM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
> Reviewing the dlmopen shared patchset, it propose the use of '#pragma once' on
> some tests header instead of include guards. I don't see an impending reason to
> not use it, however I would like to check if there any issue I am not seeing.

The POSIX filesystem API does not offer any 100% reliable mechanism
for determining whether two pathnames refer to the same file, which
means an implementation of #pragma once cannot be 100% reliable,
either.  GCC's implementation is probably as good as it can get, but
it can still make the wrong decision about whether two #include
directives refer to the same file under plausible conditions (e.g.
source on a network file system, client and server don't agree on the
current time). glibc builds use a very long list of -I switches, and
files at one point in the search path may #include files that appear
at a different point in the search path, and don't always consistently
use the same short name to do so; these factors make it more likely
that we'd actually be affected by the bugs.

My recommendation is that #pragma once should not be used anywhere in
glibc's source code.

> Besides being non standard features, it also does not really fit our requirement
> for exported headers, which usually add other headers and these check the include
> guards from 'parent' to emit an error if the these internal headers are included
> directly.

Semi-unrelated, but I think _all_ our headers should have their own
#ifdef guard, except for the few that are intended to be reread if
included a second time (e.g. bits/libc-header-start.h), which should
instead have a comment saying that they're special.

zw

      reply	other threads:[~2021-02-26 21:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26 19:10 Adhemerval Zanella
2021-02-26 21:09 ` Zack Weinberg [this message]

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

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

  git send-email \
    --in-reply-to='CAKCAbMhggO3cs6KqWPTSBotAcG=B0MEC5dUEc9fMK=JfNd4VKA@mail.gmail.com' \
    --to=zackw@panix.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=vivek@collabora.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).