Does BMax supports Compiler directives?
BlitzMax Forums/BlitzMax Beginners Area/Does BMax supports Compiler directives?
| ||
Haven't found something in the manual: Does BlitzMax support Compiler Directives, like in C, so I can build different builds of my application. For example something like this: #define SOMETHING [...] #ifdef SOMETHING [... some code here...] #endif |
| ||
there are some but they are restricted to OS compile restriction. ?Win32 ?Linux ?Mac (i think it was that) ?OS |
| ||
I recently added this to the wiki: http://www.blitzwiki.org/index.php/Category:Compiler_Directives |
| ||
bb2d/3d/plus support directives... you should use CONST CONST demo=1 IF DEMO=0 THEN ... ENDIF but i don't tested this with bbmax |
| ||
The dependent chunk of code still gets compiled if you use a constant:Const test=0 If test=1 do() EndIf 'Function do() 'EndFunction A directive removes the code before the compiler gets it. I could really use this as well. |
| ||
The const feature is sadly not present in BM But normally does not explain deep dead necromancy ^^ |
| ||
...? Const is present in Blitzmax, but using it won't preclude unused parts of the source from getting compiled into the executable... |
| ||
hmm BMK Source is open, you can Adding a System ... with ? or other sry for my english :D |
| ||
Also ?debug ?release, and was there a new one for threaded? And you can have ?not ... where ... is any of the directives |
| ||
If lline[..1]="?" Local t$=lline[1..].Trim() Local cNot If t.StartsWith( "not " ) cNot=True t=t[4..].Trim() EndIf Select t Case "" cc=True Case "debug" cc=opt_debug Case "threaded" cc=opt_threaded ?x86 Case "x86" cc=opt_arch="x86" ?ppc Case "ppc" cc=opt_arch="ppc" ? ?Win32 Case "win32" cc=True Case "win32x86" cc=opt_arch="x86" Case "win32ppc" cc=opt_arch="ppc" ?Linux Case "linux" cc=True Case "linuxx86" cc=opt_arch="x86" Case "linuxppc" cc=opt_arch="ppc" ?MacOS Case "macos" cc=True Case "macosx86" cc=opt_arch="x86" Case "macosppc" cc=opt_arch="ppc" ? Default cc=False End Select If cNot cc=Not cc Continue EndIf Some lines of "?".. you can make your own System ... |
| ||
However, it is bcc which actually parses the source and processes the directives... bcc is closed-source. If you need more compiler directives you will need to pre-process your source before passing to bmk. I believe someone (on the German forum maybe?) has done one of these. |
| ||
The dependent chunk of code still gets compiled if you use a constant: Are you sure? I think I remember reading somewhere that B3D does not compile the dependent code. I can imagine that the same would go for BMax. |
| ||
Are you sure? Try it and see... Compile an app with the Const set one way... look at the generated assm. Change the const, and look at the generated assm. :-) |
| ||
That is offcourse the best method. Here is some reference posts: http://www.blitzbasic.com/Community/posts.php?topic=41598 |
| ||
Blitz3D and BlitzPlus will not include any code that can never be executed due to a constant condition. BlitzMax compiles everything! I've just checked this with the latest version of BlitzMax as well. |