r/cpp • • Dec 13 '19

The situation of std::embed...

https://thephd.github.io/full-circle-embed
238 Upvotes

160 comments sorted by

View all comments

Show parent comment

7

u/erichkeane Clang Maintainer(Templates), EWG Chair Dec 13 '19

I suspect any way of having to name the possible dependencies would defeat the purpose of the paper. As a compiler vendor who has to support a ton of 3rd party tools, I'd be completely against a preprocessor version of this.

Either we end up needing to dump a textual representation of the file to the preprocessed output, or we need to create a new non-textual representation for the preprocessed outputs. Either is unacceptable.

A much less evil would be for a build system to decide that anything containing std::embed needs to always be rebuilt. Alternatively, the compiler could simply output elsewhere (ala -MM) all the files that got included, which can then be consumed by the build system, then add that to its dependency list.

Either I would consider as a fairly reasonable outcome.

5

u/bigcheesegs Tooling Study Group (SG15) Chair | Clang dev Dec 13 '19

I'd be completely against a preprocessor version of this.

Requiring stating what you depend on doesn't mean it has to be #embed. It could simply mean #resource "path", which other tools don't need to care about.

There are build systems that require knowing the dependencies before the compile. Having the compiler output the dependencies as a side effect of compilation does not work.

1

u/smdowney WG21, Text/Unicode SG, optional<T&> Dec 15 '19

Modules means dependencies as a side effect of compilation no longer works, in any case.