Suggestion

Blitz3D Forums/Blitz3D Programming/Suggestion

Almo(Posted 2003) [#1]
Hi!

Maybe this isn't where to post this, but I can't find a place that looks more appropriate.

It would be nice if you could conditionally tell the compiler to include code.

Like in c++:

#ifdef DEBUG
SuperSlowDebugFunction();
#endif

I'm writing a sprite manager in Blitz3D, and would like to include debug info, but don't want the debug code slowing down the release version.


Almo(Posted 2003) [#2]
Is this true? Found this on Syntax Error's Tips page...

Compiler Directives
Use constants when developing to prevent sections of code being compiled into the exe.
Blitz would NOT complie the Print statement in this example.
There will be no trace in the executable:


cbmeeks(Posted 2003) [#3]
Correct. This can be done.

Just use const.


const DEBUG = false

...

if DEBUG then
     SuperSlowDebugFunction();
end if


the "SuperSlowDebugFunction(); " would not be compiled in this example.

cb


GfK(Posted 2003) [#4]
Interesting.... never knew that.


Brendane(Posted 2003) [#5]
Is that true?
Is the block of code optimised out of compilation when using If 0 ?


jfk EO-11110(Posted 2003) [#6]
Very handy for patch-proof save-disabled demo versions etc.