How can you implement this multiline string literal macro in Swift?

后端 未结 2 601
忘掉有多难
忘掉有多难 2021-01-31 02:08

In my Objective-C code for my GPUImage framework, I have the following macro:

#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define SHADER_STRING(te         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-31 02:23

    It looks like your end goal is to avoid including standalone shader files?

    If so one technique would be to write a quick command line utility that generates a .swift file of string constants representing the shader functions in a certain folder.

    Include the resulting .swift file in your project and you have no runtime penalty, and even easier debugging if you generate the code nicely.

    Would probably take less than an hour, never need macros again for shaders.

提交回复
热议问题