With the following :
?IFDEF WIN32
?WARNING "Defining TEST"
?DEFINE TEST
?IFDEF TEST
?WARNING "Test is defined"
?ELSE
?WARNING "Test is not defined"
?ENDIF
?ELSE
?WARNING "In else"
?UNDEF TEST
?ENDIF
?IFDEF TEST
?WARNING "Test is defined"
?ELSE
?WARNING "Test is NOT defined"
?ENDIF
TEST is being defined. However, even though the else part isn't actually being executed (or doesn't appear to be), TEST is being undefined, with the result being :
"TestTType.gbas"(2) warning : preprocessor warning :
"Defining TEST"
"TestTType.gbas"(6) warning : preprocessor warning :
"Test is defined"
"TestTType.gbas"(18) warning : preprocessor warning :
"Test is NOT defined"
Is this a nested '?IFDEF' issue / bug I wonder?
Yes, sounds like it.
Aww - this little problem wasn't fixed in the update :'(
no, sorry. That's one of the big ones.
I didn't see an example of using 'AND' in a '?IFDEF' command, but you could restructure the nest using 'AND' if that is available.
If not, would it be easier to add an 'AND' option rather than making nested directives possible?
Such as:
?IFDEF WIN32
?WARNING "Defining TEST"
?DEFINE TEST
?ENDIF
?IFDEF WIN32 AND ?IFDEF TEST
?WARNING "Test is defined"
?ELSE
?WARNING "Test is not defined"
?ENDIF
?IFNDEF WIN32 AND ?IFNDEF TEST
?WARNING "In else"
?UNDEF TEST
?ENDIF
?IFDEF TEST
?WARNING "Test is defined"
?ELSE
?WARNING "Test is NOT defined"
?ENDIF
Something like that. I don't really know what you are trying to do, so the above probably doesn't make sense.
My example just shows that ?UNDEF will undefine a ?DEFINE variable, even if the code isn't executed.
It gets weirder. And it's not a nested ?IFDEF bug, as the following has no nests.
This code:
?IFDEF WIN32
?WARNING "Defining TEST"
?DEFINE TEST
//?ELSE
//?UNDEF TEST
?ENDIF
?IFDEF TEST
?WARNING "Test is defined"
?ELSE
?WARNING "Test is NOT defined"
?ENDIF
produces this output:
"IFDEF.gbas"(2) warning : preprocessor warning :
"Defining TEST"
"IFDEF.gbas"(11) warning : preprocessor warning :
"Test is NOT defined"
But remove the comments:
?IFDEF WIN32
?WARNING "Defining TEST"
?DEFINE TEST
?ENDIF
?IFDEF TEST
?WARNING "Test is defined"
?ELSE
?WARNING "Test is NOT defined"
?ENDIF
produces this:
"IFDEF.gbas"(2) warning : preprocessor warning :
"Defining TEST"
"IFDEF.gbas"(7) warning : preprocessor warning :
"Test is defined"
You can't comment precompiler directives?
[Edit]
It's like any reference to '?UNDEF' (comment out or not) ignores any '?IF' structures and is always executed.
I think any ?UNDEF reached will remove the defined variable no matter if its in the same block as ?DEFINE or not - and no matter whether its commented or not.
I had thought it was an ?ELSE problem, but I think you've shown it isn't :)
Ah. ?UNDEF was always executed. I fixed it and do an update now.