Conditional compile
BlitzMax Forums/BlitzMax Programming/Conditional compile
| ||
Another Q: Is it possible to use conditional compilation? |
| ||
good question. |
| ||
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. |
| ||
?MacOS ?Win32 ?Linux ? |
| ||
You can also define which modules get compiled in your executable with Import and/or Framework. |
| ||
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 |
| ||
That is correct. |
| ||
If that's true, then const x:int = false print "Hello" if x then x.ggg endif should compile. Which it doesn't. |
| ||
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. |
| ||
Yes, but that doesn't prove that the if stuff was not compiled. That is what he was trying to do... |
| ||
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 |