• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Nested Preprocessor Conditions

-=THOR=-

Grizzled Veteran
Sep 20, 2011
1,050
50
Try this code with the -intermediate option.

Code:
`if(`isdefined(SomeUndefinedConstant))
`ifndef(ShippingPC)
    ...
`endif
Some stuff that should not be outputted.
`endif
If you look under ROGame\PreProcessedFiles, you will find:

Code:
Some stuff that should not be outputted.
Odd, isn't it? Now try this:

Code:
`if(`isdefined(SomeUndefinedConstant))
`if(`notdefined(ShippingPC))
    ...
`endif
Some stuff that should not be here.
`endif
You get the expected behavior: nothing is outputted to the intermediate file.

Now my question is: WTH? Am I missing something or is the preprocessor broken? In the first code block it seems that the first endif is applied to the 1st if :/

Another oddity... I found this in PlayerController.uc:
`if(`notdefined(FINAL_RELEASE) || `isdefined(RO_))

I assumed that || was supported. But after trying, it seems that it is not. In my code, I had to append both preprocessor commands like this to get the desired behavior:

`if(`notdefined(FINAL_RELEASE)`isdefined(RO_))

It seems that || is considered a string, which makes `if always return true. Any thoughts?
 
Last edited:
Welcome to the club. Had the same problems with the ladder mutator and the exploit offspring. They shared the same code, though parts were filtered out at pre-process level. Took me quite some time to get it rightly filtered. The things that I noticed were that || and && do not work as expected. I did however not have any problems with the nesting.
 
Upvote 0
Damn... so I was not crazy ^^

Then the 'workaround guide' would be:

`if(`A && `B)
...
`endif
becomes
`if(`A)
`if(`B)
...
`endif
`endif

`if(`A || `B)
...
`endif
becomes
`if(`A`B)
...
`endif

`ifndef(A)
...
`endif
becomes
`if(`notdefined(A))
...
`endif

Although the last one doesn't trigger an error when alone, it will when surrounded by other conditions. Idk if it's the case, but I suspect that `ifdef could have the same problem.
 
Last edited:
Upvote 0