且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C / C ++,你可以#包括文件到一个字符串?

更新时间:2023-11-17 18:13:10

的C / C ++ preprocessor行为在令牌单位,一个字串是的的标记。因此,你不能在一个字符串一样,中间的干预。

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.

您可以preprocess script.py成类似:

You could preprocess script.py into something like:

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

和的#include的,但是。或者你可以使用 XXD -i 来生成一个C静态数组准备列入。

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