Date: Mon, 2 Sep 2024 10:21:04 +0100
On Mon, 2 Sept 2024 at 09:53, Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Hi Gašper,
>
>
>
> perhaps my answer was too fast.
>
>
>
> I was trying to go a third way:
>
> Neither content nor local file identity, but using the path given in the
> #include files.
>
>
>
> Difficulties arise from the facts
>
> - that libraries have several entry points for their includes, possibly
> in subdirectories.
>
> - that -I include directories may point to one or several libraries
>
> - that some libraries would need several -I parameters, e.g. for
> sub-components or plugins
>
>
>
> Perhaps a working solution would be to create a #once only working for
> #include "".
>
The behaviour of #include "" is implementation-defined. The common
"relative to the file doing the including" behaviour is not required by the
standard.
> After including a library with a search path with <>, all subsequent
> includes with "" are seen relative to the current file.
>
>
>
> (Some compilers provide more complicated options to also extend a search
> path for "" or do so with the paths of all previously included files, but
> those extended lookup paths are not standard.)
>
>
>
> With those files at least it should be possible to rely solely on the
> paths provided in the #include "" directives.
>
>
>
>
>
> What to do with
>
>
>
> main.cpp
>
> #include <mylib/librarydefs.h>
>
> #include <mylib/constants.h>
>
> librarydefs.h:
>
> #include "constants.h"
>
>
>
> librarytemplates.h:
>
> #include "constants.h"
>
>
>
> constants.h:
> #once
>
>
>
>
>
> We would have to know that both includes in main point to the same library.
>
>
>
> That could get more difficult with
>
>
>
> -I /includes/alllibs -I /specialincludes/mylibplugins
>
>
>
> On the other hand, #include "" probably would not work now either between
> those subcomponents of the library.
>
>
>
> So we could limit #once to work only within one -I path (or of course in
> the cpp file, as long as #include "" is used locally)
>
>
>
>
>
>
>
> Not sure, if it is worth it, as it is only a partly solution (only
> #include "") and is different from all the existing #pragma once
> implementations. And perhaps I have not seen some of the possible pitfalls.
>
>
>
>
>
std-proposals_at_[hidden]> wrote:
> Hi Gašper,
>
>
>
> perhaps my answer was too fast.
>
>
>
> I was trying to go a third way:
>
> Neither content nor local file identity, but using the path given in the
> #include files.
>
>
>
> Difficulties arise from the facts
>
> - that libraries have several entry points for their includes, possibly
> in subdirectories.
>
> - that -I include directories may point to one or several libraries
>
> - that some libraries would need several -I parameters, e.g. for
> sub-components or plugins
>
>
>
> Perhaps a working solution would be to create a #once only working for
> #include "".
>
The behaviour of #include "" is implementation-defined. The common
"relative to the file doing the including" behaviour is not required by the
standard.
> After including a library with a search path with <>, all subsequent
> includes with "" are seen relative to the current file.
>
>
>
> (Some compilers provide more complicated options to also extend a search
> path for "" or do so with the paths of all previously included files, but
> those extended lookup paths are not standard.)
>
>
>
> With those files at least it should be possible to rely solely on the
> paths provided in the #include "" directives.
>
>
>
>
>
> What to do with
>
>
>
> main.cpp
>
> #include <mylib/librarydefs.h>
>
> #include <mylib/constants.h>
>
> librarydefs.h:
>
> #include "constants.h"
>
>
>
> librarytemplates.h:
>
> #include "constants.h"
>
>
>
> constants.h:
> #once
>
>
>
>
>
> We would have to know that both includes in main point to the same library.
>
>
>
> That could get more difficult with
>
>
>
> -I /includes/alllibs -I /specialincludes/mylibplugins
>
>
>
> On the other hand, #include "" probably would not work now either between
> those subcomponents of the library.
>
>
>
> So we could limit #once to work only within one -I path (or of course in
> the cpp file, as long as #include "" is used locally)
>
>
>
>
>
>
>
> Not sure, if it is worth it, as it is only a partly solution (only
> #include "") and is different from all the existing #pragma once
> implementations. And perhaps I have not seen some of the possible pitfalls.
>
>
>
>
>
Received on 2024-09-02 09:22:22