Conditional compile

BlitzMax Forums/BlitzMax Programming/Conditional compile

zeedoktor(Posted 2004) [#1]
Another Q:
Is it possible to use conditional compilation?


smilertoo(Posted 2004) [#2]
good question.


skidracer(Posted 2004) [#3]
As with BlitzPlus and Blitz3D the compiler will not output code inside an If statement if the expression is Const and False.

There are also built in compiler directives for supporting conditional compiling based on target platform using the ? operator.


Perturbatio(Posted 2004) [#4]
?MacOS

?Win32

?Linux

?


soja(Posted 2004) [#5]
You can also define which modules get compiled in your executable with Import and/or Framework.


zeedoktor(Posted 2004) [#6]
Ok, I remain confused about this whole issue. Maybe some staff could respond?

Given this pseudo code, the code within If DEBUG Then ... would not even be compiled if DEBUG = 0?

Const DEBUG = 0

If DEBUG Then
do debug stuff
End If


Hotcakes(Posted 2004) [#7]
That is correct.


watusimoto(Posted 2007) [#8]
If that's true, then

const x:int = false

print "Hello"

if x then
x.ggg
endif

should compile. Which it doesn't.


klepto2(Posted 2007) [#9]
Thats not a compiler problem its more a parser/lexer problem.
you want to access a field of x (x.ggg) which doesn't exist because x is just an integer and not an object.

const x:int = false

print "Hello"

if x then
Print "X <> False"
endif


This should compile.


TaskMaster(Posted 2007) [#10]
Yes, but that doesn't prove that the if stuff was not compiled. That is what he was trying to do...


Dreamora(Posted 2007) [#11]
Its quite simple to check.

Compile it with a specific string in the part that is "never reached" due to const - if
If that string appears in the executable (take nodepad or wordpad) it does not cut out never reached code.

This was the default behavior until and with 1.24.
Not tested with 1.26


Any real way to get a conditional compiling would be the addition of own ?XXX flags to BMK