C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Wed, 28 Aug 2024 10:29:34 +0300
On Wed, 28 Aug 2024 at 10:22, Lénárd Szolnoki via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> 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.

Excellent points. And yes, that would be in scope for SG15, they have
worked on similar recommendations for unifying functionality in other
areas.

It's a whole other discussion whether they consider #pragma once worth
spending energy on.

Received on 2024-08-28 07:29:49