Does BMax supports Compiler directives?

BlitzMax Forums/BlitzMax Beginners Area/Does BMax supports Compiler directives?

maverick69(Posted 2005) [#1]
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




Dreamora(Posted 2005) [#2]
there are some but they are restricted to OS compile restriction.

?Win32
?Linux
?Mac (i think it was that)
?OS


Perturbatio(Posted 2005) [#3]
I recently added this to the wiki:
http://www.blitzwiki.org/index.php/Category:Compiler_Directives


MrCredo(Posted 2005) [#4]
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


JoshK(Posted 2009) [#5]
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.


Dreamora(Posted 2009) [#6]
The const feature is sadly not present in BM
But normally does not explain deep dead necromancy ^^


xlsior(Posted 2009) [#7]
...?

Const is present in Blitzmax, but using it won't preclude unused parts of the source from getting compiled into the executable...


kog(Posted 2009) [#8]
hmm BMK Source is open, you can Adding a System ... with ? or other

sry for my english :D


Mark Tiffany(Posted 2009) [#9]
Also ?debug ?release, and was there a new one for threaded?

And you can have ?not ... where ... is any of the directives


kog(Posted 2009) [#10]
			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 ...


Brucey(Posted 2009) [#11]
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.


Warner(Posted 2009) [#12]
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.


Brucey(Posted 2009) [#13]
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.

:-)


Warner(Posted 2009) [#14]
That is offcourse the best method. Here is some reference posts:
http://www.blitzbasic.com/Community/posts.php?topic=41598


JazzieB(Posted 2009) [#15]
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.