Include file as string

Is there a preprocessing trick that allows me to “include” the file as a line in the header?

Something like that:

a.txt

lorem ipsum dolorem
sit amet

and "magic" include a call similar to this:

header.h

MAGICINCLUDE(a.txt, atxt)

As a result, the preprocessor does the tricks, and the above line is equivalent to this:

const char* atxt = "lorem ipsum dolorem\n\
sit amet";

No external tool should be used, just a preprocessor: I'm trying to get rid of my python scripts that do this.

+4
source share

Source: https://habr.com/ru/post/1674211/


All Articles