C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Tue, 27 Aug 2024 20:28:18 +0300
On 8/27/24 20:14, Jeremy Rifkin wrote:
> Does using contents for #pragma once break any practical or plausible
> uses of #pragma once? Does it have any clear downsides?

Yes, it does. It makes the behavior different from what is expected by
majority of users. And is prone to subtle errors, if different headers
happen to match in contents.

> I don’t think does. It should only make things more robust and portable.
>
> Jeremy
>
> On Tue, Aug 27, 2024 at 12:07 Andrey Semashev via Std-Proposals
> <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>>
> wrote:
>
> On 8/27/24 17:01, Jeremy Rifkin via Std-Proposals wrote:
> > Hi,
> > I have drafted a proposal for standardizing #pragma once. This has
> been
> > previously proposed a few years ago and I recognize that on top of
> being
> > difficult to standardize, existing opinions on this topic may
> render the
> > paper dead on arrival. However, due to its widespread nature and
> > concerns about portability contributing to it not being used more I
> > think it's worth revisiting. I have uploaded the first draft at:
> >
> https://jeremy-rifkin.github.io/cpp-proposals/drafts/pragma-once-draft-1.html <https://jeremy-rifkin.github.io/cpp-proposals/drafts/pragma-once-draft-1.html> <https://jeremy-rifkin.github.io/cpp-proposals/drafts/pragma-once-draft-1.html <https://jeremy-rifkin.github.io/cpp-proposals/drafts/pragma-once-draft-1.html>>.
>
> I think, using file contents for `#pragma once` is wrong and should not
> be standardized. The intended effect of `#pragma once` has always been
> to avoid including *the same header* twice, not *the same content*.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden] <mailto:Std-Proposals_at_[hidden]>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> <https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>
>

Received on 2024-08-27 17:28:31