From 145a0f634ac8fb5cefe081237be1610740dd339a Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 20 Dec 2022 00:20:24 +0800 Subject: Correct user guide's section on preprocessor directives (#2565) --- docs/api-users-guide.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/api-users-guide.md b/docs/api-users-guide.md index d8ab31bc4..1d33c924f 100644 --- a/docs/api-users-guide.md +++ b/docs/api-users-guide.md @@ -92,11 +92,14 @@ If you want any kind of preprocessor macros to be defined when compiling your co spAddPreprocessorDefine(request, "ENABLE_FOO", "1") ``` -Note that Slang currently doesn't provide an automatic definition like `__SLANG__` to identify the compiler, so you might want to do that manually, if you need to have files that are processed by Slang and other tools. +Slang provides the following preprocessor definitions: -```c++ -spAddPreprocessorDefine(request, "__SLANG__", "1") -``` +- `__SLANG_COMPILER__` as `1` +- `__SLANG__` as `1` when compiling in Slang mode and `0` when compiling in HLSL mode. +- `__HLSL__` as `1` when compiling in HLSL mode and `0` when compiling in Slang mode. +- `__HLSL_VERSION` as an integer representing the HLSL language version. + +Note that `__SLANG__` and `__HLSL__` are *always* defined, so best to use a truthiness check such as `#if __SLANG__` to guard code. ### Specify Input Code and Entry Points -- cgit v1.2.3