C++ Logo

sg15

Advanced search

Re: "logical name" of importable headers

From: Daniel Ruoso <daniel_at_[hidden]>
Date: Mon, 6 Jun 2022 11:19:08 -0400
Em seg., 6 de jun. de 2022 às 10:39, Gabriel Dos Reis
<gdr_at_[hidden]> escreveu:
> I don't know if I answered that question earlier; if I did then my
> apologies for the repeat.
> MSVC uses header-units.json:
> https://docs.microsoft.com/en-us/cpp/build/reference/header-unit-json-reference?view=msvc-170

Right, I was looking at that, but that format currently doesn't cover
the distinctions we were making before, particularly around "should
this header unit only be accessible through the specific token?"
"should it be found by include directory lookup and then map to a
header unit regardless of the token used?". That's the question I'm
trying to answer.

At this point, I'm proposing we take a more aggressive stance on this
particular problem.

My proposal is that we recommend a convention where the assignment of
header units takes precedence over the include directory lookup.

Specifically, the input to the compiler would be a map from the token
used after include or import to the header file and the bmi for that
header unit.

Essentially, any token listed as a header unit is no longer subject to
search in the include directories, and is just straight out mapped to
the specific header file for inclusion and bmi for importation. And it
becomes a straight error to attempt to map the same token to different
headers.

IMHO, that simplifies a lot of the semantics on how distributed
libraries need to advertise their headers, and maybe it even gets us
to a point where a library doesn't need a `-I` anymore.

daniel

Received on 2022-06-06 15:19:20