Thanks for the response Gavin.
>
corrected a #define that you were missing
The define for BAZ isn't missing. Its nested inside the elif logic where FOO == "baz". This logic should be unreachable and thrown out by the preprocessor anyway. It is correct and should work but if it wasn't correct shouldn't it have been thrown away anyway?
I might be confusing myself or misunderstanding how the ISPP should work. If so I apologize. Below I will try to provide more examples that should all work. They should show how the ISPP is behaving inside unreachable elif logic. I've also added line numbers to make it easier to talk about specific lines. It might not be so fun to copy/paste so I'll zip up and attached these examples.
examples-set-2-ex-1
This on its own should work but it will fail.
Error: line 7: column 11: Undeclared identifier: BAZ
- Note 1: Lines 5-8 inclusive should not fail and won't on their own while not nested in an elif.
- Note 2: Lines 5-8 inclusive should have been thrown out by ISPP and never processed. Even if they were incorrect it shouldn't care.
```
1| #define FOO "foo"
2| #if FOO == "foo"
3| #define FOO "bar"
4| #elif FOO == "baz"
5| #ifndef BAZ
6| #define BAZ "foo"
7| #elif BAZ == "bar"
8| #endif
9| #endif
```
examples-set-2-ex-2
If lines 5 and 6 are removed, from examples-set-2-ex-1, and the elif is corrected to be if, it will work.
(note I renumbered the lines in the below example after removing line 5&6 from examples-set-2-ex-1)
- Note 1: Lines 5-6 inclusive should fail on their own when not nested in an elif. (see examples-set-2-ex-3)
- Note 2: I believe this isn't failing because the ISPP is correctly throwing those lines away since they are unreachable.
```
1| #define FOO "foo"
2| #if FOO == "foo"
3| #define FOO "bar"
4| #elif FOO == "baz"
5| #if BAZ == "bar"
6| #endif
7| #endif
```
examples-set-2-ex-3
If lines 5 and 6 from examples-set-2-ex-2 were on their own they will fail.
(note: I renumbered 5 & 6 from examples-set-2-ex-2 to 1 & 2 respectfully).
Error: Line 1: Column 9: Undeclared Identifier: BAZ
```
1| #if BAZ == "bar"
2| #endif
```
It seems like the ISPP will jump into the unreachable portion of an elif if there is an ifndef in it. Then it will throw that ifndef away but still process the remainder of what should be unreachable.
examples-set-2-ex-4
If the ifndef->elif->endif were broken into two stand alone if blocks, ifndef->endif and if->endif, it will work.
Something is breaking when ifndef->elif->endif is contained in an unreachable elif.
Key word being "unreachable". If the logic were in reachable code the ISPP would process it correctly. (see examples-set-2-ex-5)
```
1| #define FOO "foo"
2| #if FOO == "foo"
3| #define FOO "bar"
4| #elif FOO == "baz"
5| #ifndef BAZ
6| #define BAZ "foo"
7| #endif
8| #if BAZ == "bar"
9| #endif
10| #endif
```
examples-set-2-ex-5
Code in question is now in reachable elif. The only thing I changed from examples-set-2-exe-1 was #define FOO as "baz" instead of "foo".
```
1| #define FOO "baz"
2| #if FOO == "foo"
3| #define FOO "bar"
4| #elif FOO == "baz"
5| #ifndef BAZ
6| #define BAZ "foo"
7| #elif BAZ == "bar"
8| #endif
9| #endif
```