C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Avi Kivity <avi_at_[hidden]>
Date: Sun, 29 Sep 2024 23:05:03 +0300
On Mon, 2024-09-02 at 09:57 -0700, Thiago Macieira via Std-Proposals
wrote:
> On Monday 2 September 2024 05:24:29 GMT-7 Tiago Freire via Std-
> Proposals
> wrote:
> > I have given you a detailed explanation of the minimum set of
> > complexity
> > that is required of a project to even hit such a problem. And have
> > showed
> > you how that minimum set must include doing things that are
> > considered bad
> > practice.
>
> Bad practice or not, they exist.
>
> Here's a simple one that has one such bad practice: vendoring
> content.
>
> I have a project that has two vendored libraries I need, and one of
> them
> vendors the other one to. We can call them libpng and zlib, or oneDNN
> and
> Xbyak, or some other pair.
>
> if, during the compilation of one of my files, both sets of headers
> are found
> by -I options and at least one copy uses #pragma once, my build will
> fail.
>


Would a compiler option -fno-pragma-once-inode-matching work?

The standard could define #pragma once to match on contents, and allow
implementations to "optimize" the content comparison by using
inodes/mtimes/whatever. Complex builds would ask the implementation to
skip the optimization.

(well the talk about "optimization" could be left out of the standard,
and implementations would choose what default they thing best)


Received on 2024-09-29 20:05:10