Is there a way to read content of C++ raw string literal from non C/C++ file?

Viewed 798

Is there a way to read content of C++ raw string literal from non C/C++ file (at compile time - i.e. make it hard-coded into resulting unit?

The C++ has nice raw string literals e.g.

const char* const cstring = 
R"myheredoc(
       do ;*!$%@#
       whatever 
       you want here
)myheredoc";

Is there however a way how to read the content of the raw string from a file which is non C++ (e.g. example configuration file).

I can imagine that this can be done by build system, just want to know that I did not miss anything from the great new C++ features.

1 Answers

Currently C++ has no way to accomplish it, short of relying on the preprocessor and the build system.

While you could accomplish it with an auto-generated header/source file that is #includeed by the preprocessor, that is a somewhat sorry state of affairs. So there is currently a paper in flight for C++20, proposing the aptly named std::embed. It will allow to do what you are after, pretty much, if it is ever voted into the C++ standard. So stay tuned.

Related