yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jsmall-nvidiaSupport for __LINE__ and __FILE__ in preprocessor (#1772)5fde038b1

master
765 B37 linesraw
1//DIAGNOSTIC_TEST:SIMPLE:-E
2
3// Testing of handling of __LINE__ in macros
4// Pasting, and some other aspects.
5
6
7// Lets try some macro pasting. NOTE strictly speaking we need CONCAT2 (as tested on other compilers, but Slang does not indicating a preprocessor bug!)
8#define CONCAT2(x, y) x ## y
9#define CONCAT(x, y) CONCAT2(x, y)
10
11CONCAT(Thing, __LINE__)
12
13// Lets see if works okay in conditionals
14
15#if __LINE__ == 15
16Yeppers
17#else
18Nopers
19#endif
20
21// Lets try a paste in a conditional
22#if CONCAT(__LINE__, __LINE__) == 2222
23PasteConditional
24#endif
25
26// Lets check that we pick up the nominal line
27#line 10
28__LINE__
29
30// Reset the line numbering
31#line default
32
33// __LINE__ number will be for the macro invocation, not the expansion
34
35#define SOMEMACRO __LINE__
36
37SOMEMACRO