How can I get the contents of a file at build time into my C++ string?

后端 未结 5 1471
猫巷女王i
猫巷女王i 2021-01-14 00:05

I have a file I am compiling in C++ in which I wish to have a string whose value is the contents of a file at the time of compilation.

In other words, I\'d like to #

5条回答
  •  伪装坚强ぢ
    2021-01-14 00:43

    To correctly create a header with the correct null termination in the string use sed:

    xxd -i ${INPUT_FILE_NAME} | sed s/}\;/,0x00}\;/ > ${INPUT_FILE_PATH}.h
    

    See http://gamesfromwithin.com/quick-tip-working-with-shaders-on-ios for details.

提交回复
热议问题