HLSL #pragma once 等效?
HLSL #pragma once equivalent?
什么等同于 HLSL 中的 C/C++-like #pragma once
includes?
我想要(作为一个人为的例子):
// ./dependency.hlsl
float x() { return 0; }
// ./shader.hlsl
#include "./dependency.hlsl" // (./ unnecessary; for question readability)
#include "./dependency.hlsl"
不会因 error X3003: redefinition of 'x'
而失败。 #pragma once
在我的文件顶部产生了一个非错误 warning X3568: 'once' : unknown pragma ignored
并且什么都不做!
使用 C/C++ 类似宏的包含守卫。设计的 dependency.hlsl
看起来如下:
#ifndef __DEPENDENCY_HLSL__
#define __DEPENDENCY_HLSL__
float x() { return 0; }
#endif // __DEPENDENCY_HLSL__
什么等同于 HLSL 中的 C/C++-like #pragma once
includes?
我想要(作为一个人为的例子):
// ./dependency.hlsl
float x() { return 0; }
// ./shader.hlsl
#include "./dependency.hlsl" // (./ unnecessary; for question readability)
#include "./dependency.hlsl"
不会因 error X3003: redefinition of 'x'
而失败。 #pragma once
在我的文件顶部产生了一个非错误 warning X3568: 'once' : unknown pragma ignored
并且什么都不做!
使用 C/C++ 类似宏的包含守卫。设计的 dependency.hlsl
看起来如下:
#ifndef __DEPENDENCY_HLSL__
#define __DEPENDENCY_HLSL__
float x() { return 0; }
#endif // __DEPENDENCY_HLSL__