C++ Logo


Advanced search

Re: [wg14/wg21 liaison] #once proposal

From: Miguel Ojeda <miguel.ojeda.sandonis_at_[hidden]>
Date: Thu, 3 Feb 2022 20:50:30 +0100
On Thu, Feb 3, 2022 at 8:29 PM Steve Downey via Liaison
<liaison_at_[hidden]> wrote:
> I see that there's yet another proposal for standardization of pragma once on the agenda for C?

What do you mean by "yet another"? There is prior art, but as far as I
know, it is the first time it is presented in WG14.

> Is there any chance that this gets adopted? Because at scale it doesn't work, and causes both structural and transient problems, and it will be even harder to get people not to use it if it's in the standard.

Of course there is a chance -- as with any other proposal. The
no-identifier form does have pitfalls depending on how a compiler
defines it, but it is widely used everywhere. The paper is
standardizing existing practice (and, by doing that, asking compilers
to document it).

Of course, we may decide to standardize only the identifier form, and
then people might be more compelled to use the identifier way. I tend
to think most people using `#pragma once` do so because it is short.
Thus the identifier form is a middle ground that is still short yet
has defined, portable behavior.

> The include guard replacement form would be OK, but also doesn't fix the common complaints about guards, that it suffers from collision and cut/paste errors.

The cut/paste errors within the file are handled -- do you mean
repeating the same identifier in several files by copy-pasting?


Received on 2022-02-03 19:50:42