C/C++, can you #include a file into a string literal? [duplicate]

The C/C++ preprocessor acts in units of tokens, and a string literal is a single token. As such, you can’t intervene in the middle of a string literal like that.

You could preprocess script.py into something like:

"some code\n"
"some more code that will be appended\n"

and #include that, however. Or you can use xxd​ -i to generate a C static array ready for inclusion.

Leave a Comment