Description
Hi,
Consider we have an hlsl file with two includes that both include a same third file, but with different character case. pragma once will then fail to detect them as the same include and will report symbol redefinitions errors for example.
A simple example
cs_pragma_hlsli:
#pragma once
struct Foo
{
float4 m_scale;
};
includeA.hlsli:
#pragma once
#include "cs_pragma.hlsli"
includeB.hlsli:
#pragma once
#include "cs_Pragma.hlsli" // notice the 'P' instead of 'p'
main file cs_pragma.hlsl, to be compiled with -T cs_6_6:
#include "includeA.hlsli"
#include "includeB.hlsli"
RWTexture2D<float4> myOutput: register(u0);
Texture2D<float4> myTexInput: register(t0);
ConstantBuffer<Foo> Bar: register(b0);
[RootSignature("RootFlags(0), DescriptorTable(UAV(u0), CBV(b0), SRV(t0))")]
[numthreads(8, 8, 1)]
void main(uint3 thread_id : SV_DispatchThreadID)
{
float4 outValue = myTexInput.Load(int3(thread_id.xy, 0));
myOutput[thread_id.xy] = outValue * Bar.m_scale;
}
preprocessed code in godbolt: https://godbolt.org/z/qdosafc4E
Actual Behavior
Output of the example above:
E:\Temp\pragma_once\dxc_2026_05_27\bin\x64>dxc -T cs_6_6 e:\temp\pragma_once\cs_pragma.hlsl
In file included from e:\temp\pragma_once\cs_pragma.hlsl:2:
In file included from e:\temp\pragma_once/includeB.hlsli:3:
e:\temp\pragma_once/cs_Pragma.hlsli:3:8: error: redefinition of 'Foo'
struct Foo
^
e:\temp\pragma_once/cs_pragma.hlsli:3:8: note: previous definition is here
struct Foo
^
E:\Temp\pragma_once\dxc_2026_05_27\bin\x64>
Environment
- DXC version: 1.9(5191-d355aa83)(1.9.2602.24) - 1.9.2602.24 (d355aa8)
- Host Operating System: Windows11 23H2 22631.6936
This mostly prevents us from using pragma once on a non case sensitive file system such as windows.
Best!
Olivier
Description
Hi,
Consider we have an hlsl file with two includes that both include a same third file, but with different character case.
pragma oncewill then fail to detect them as the same include and will report symbol redefinitions errors for example.A simple example
cs_pragma_hlsli:
includeA.hlsli:
includeB.hlsli:
main file cs_pragma.hlsl, to be compiled with -T cs_6_6:
preprocessed code in godbolt: https://godbolt.org/z/qdosafc4E
Actual Behavior
Output of the example above:
Environment
This mostly prevents us from using
pragma onceon a non case sensitive file system such as windows.Best!
Olivier