C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Wed, 28 Aug 2024 08:22:19 +0100
On 27 August 2024 21:17:04 BST, Ville Voutilainen via Std-Proposals <std-proposals_at_[hidden]> wrote:
>On Tue, 27 Aug 2024 at 23:09, Tiago Freire via Std-Proposals
><std-proposals_at_[hidden]> wrote:
>> Whatever that means for that system it’s an implementation detail, left for the compiler vendor as an exercise.
>
>Well, if that's what you want, we can end this discussion here.
>There's nothing to standardize. Just use #pragma once.

Note that how #include finds files itself is implementation-defined (import too, BTW), yet it's in the standard, and we can use #include more or less portably.

There is one major difference in practice between the two: As a user I have some control over the implementation-defined behaviour of #include by specifying compiler flags (-I <path>). AFAIK I have no control over how #pragma once determines if two files are equivalent for the purpose of inclusion.

If there were such control in a way that build systems targeting multiple compilers could effectively make use of that, then I think that would make it more palateable for having it in the standard. After all, we do have #include and import with similar level of implementation-defined behaviour.

Build systems would probably like full control over what files are considered equivalent removing all compiler heuristics (inode, mtime, content,...). Possibly replacing it with build system heuristics or passing this control over further up to the user.

Anyway, such compiler flags should come first before consideration of adding #pragma once to the standard. But even if it's out of scope for the C++ standard, it might still be in scope for SG15 Tooling, although admittedly I don't follow their activity.

Cheers,
Lénárd


>--
>Std-Proposals mailing list
>Std-Proposals_at_[hidden]
>https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-08-28 07:22:23