C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Mon, 2 Sep 2024 15:22:39 +0300
On Mon, 2 Sept 2024 at 15:18, Jonathan Wakely <cxx_at_[hidden]> wrote:
>
>
>
> On Mon, 2 Sept 2024 at 13:12, Tiago Freire <tmiguelf_at_[hidden]> wrote:
>>
>> > The (main) problem has never been two distinct files having the same path. The problem is one and the same file having different paths (and inodes, etc.).
>> It fails to be recognized as the Same File in multiple places, attempts to redefine non-inline entities, and builds break.
>>
>> Great, don't do that then!
>
>
> I think it's time you write a proposal for standardizing this simplistic form of #pragma once, and explain why the existing implementations that do something more complicated are unnecessary and should be changed to not do that.
>
> Otherwise this discussion is going round in circles and you'll just keep insisting that the simplistic implementation is the right one, while others insist it doesn't work well enough.

I will then actually write that counter-proposal that borrows most of
the building blocks in Jeremy's paper, but proposes that
a #pragma once encountered in a C++ program makes the program
ill-formed. After all, the opponents of standardizing this idea are
being
accused of forcing people to use include guards instead of #pragma
once, so it's just better to have a proposal that makes those
accusations
be true. Those who don't want their builds to become broken can then
simply change their builds to request a non-standard mode from their
compilers that doesn't reject a #pragma once.

After all, changing builds that you have carefully designed to suit
your needs is a trivial exercise. Fair's fair.

Received on 2024-09-02 12:22:54