HLSL #pragma曾经等同?

时间:2017-12-26 11:59:15

标签: include shader direct3d hlsl pragma

与C / C ++相同的是什么 - 比如HLSL中的#pragma once包括哪些?

我想(作为一个人为的例子):

// ./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并且什么都不做!

1 个答案:

答案 0 :(得分:4)

使用C / C ++类宏包含警戒。人为的dependency.hlsl看起来如下:

#ifndef __DEPENDENCY_HLSL__
#define __DEPENDENCY_HLSL__

float x() { return 0; }

#endif // __DEPENDENCY_HLSL__
相关问题