KhronosGroup / KhronosGroup/glslang
Invalid escape sequence produced after __FILE__ replacement on Windows
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
I am encountering "invalid escape sequence" error after trying to compile a preprocessed GLSL shader on Windows.
If we look into the preprocessed file, I can observe those two things:
- `#line 1 "src\shaders\include/bar.h"`
- `[...] debugPrintfEXT("Condition failed %s:%d : %s", "src\shaders\foo.rgen", 13, "Launching Ray Generation shader"); [...]`
Those string are not correct because the `\` is unescaped and produces a invalid string.
Moreover, it seems that this is a opportunity to make things more consistent by using consistently `\` on Windows and `/` on UNIX platform for example.
Is this a known issue ?
Note that I may not be fully aware of the requirements for the `#line` directive so feel free to suggest any other alternative which may improve this situation
Below is my minimal repro case
Using 2 files
`bar.h`
```glsl
#ifdef DEBUG
#define ASSERT_MESSAGE(expr, message) do { if (!(expr)) { debugPrintfEXT("Condition failed %s:%d : %s", __FILE__, __LINE__, message); } } while(false)
#else
#define ASSERT_MESSAGE(expr, message)
#endif
```
`foo.rgen`
```glsl
#version 460
#extension GL_EXT_ray_tracing : require
#extension GL_GOOGLE_include_directive : require
#ifdef DEBUG
#extension GL_EXT_debug_printf : enable
#endif
#include "bar.h"
void main() {
ASSERT_MESSAGE(gl_LaunchIDEXT.x > 0 && gl_LaunchIDEXT.y > 0, "Launching Ray Generation shader");
}
```
Organised as follow
```
└ src
│ foo.rgen
└─ include
└─ bar.h
```
With working directory in ``, I compile this dummy shader in 2 steps :
1. `glslc --target-env=vulkan1.2 -DDEBUG -I src\shaders\include -E src\shaders\foo.rgen -o preprocessed-foo.rgen`
2. `glslc --target-env=vulkan1.2 preprocessed-foo.rgen -o foo.spv`
Which produces the following
```
src\shaders\foo.rgen:13: error: 'string' : Invalid escape sequence
1 error generated.
```
glslc version
```
λ glslc --version
shaderc v2020.5 v2020.5
spirv-tools v2021.0-dev v2020.7-2-gef3290bb
glslang 11.1.0-52-ge56beaee
Target: SPIR-V 1.0
```
Contributor guide
Assessment
This issue has not been assessed yet.