Page 1 of 1

Funny christmas bug

Posted: Wed Dec 29, 2010 8:56 pm
by max_aigneraigner@web.de
Hi Forum,

we were just messing a bit around in the german purebasic forum,
and found SUDDENLY this .. comic.. mistake..

watch the amount of compilerendif / compilerif - s..

Code: Select all

Macro If_Home_is_defined
  CompilerIf ((~Defined(home,#PB_Constant)) & %00000001)
EndMacro 

Macro then_write_hello
  Debug "hallo"
EndMacro 

Macro and_go_Home
   CompilerEndIf 
EndMacro 

; ------------------------------------------------------------
; ----DELETE THIS CONSTANT to see the MIRACLE --------------
; ------------------------------------------------------------

#home = 1


; ----

If_Home_is_defined
then_write_hello
and_go_Home
CompilerEndIf
Amazing, right?
bug or not?

:)

merry christmas and a happy new year

-walker

on purebasic 4.51 *86 windows 7 etc..

Re: Funny christmas bug

Posted: Wed Dec 29, 2010 11:23 pm
by freak
This is correct. Code between CompilerIf and CompilerEndIf is not compiled, so 'and_go_Home' never gets expanded. There is just one CompilerEndIf.

Re: Funny christmas bug

Posted: Wed Dec 29, 2010 11:31 pm
by blueznl
Not a bug. Though a bit unexpected :-)

None of the code between CompilerIf / CompilerEndIf seems to be processed, including any macros...

This behaves the same:

Code: Select all

Macro x_compilerendif
  CompilerEndIf
EndMacro
;
#home = 1
;
CompilerIf ((~Defined(home,#PB_Constant)) & %00000001)
  Debug "hallo"
  x_compilerendif
CompilerEndIf
And this shows what happens:

Code: Select all

Macro x_compilerendif
  CompilerEndIf
EndMacro
;
#home = 1
;
CompilerIf ((~Defined(home,#PB_Constant)) & %00000001)
  Debug "hallo"
x_compilerendif

Re: Funny christmas bug

Posted: Fri Dec 31, 2010 10:17 pm
by max_aigneraigner@web.de
Damn Axe.. we say in bavaria.. (verdammte Axt..)
so compilerif has a higher priority than a macro o.O...
I would like to choose the priority.. well.. in this case ^^ :)

ok, so thanks for helping again :)

and have a good flush into the next year :)

Re: Funny christmas bug

Posted: Sat Jan 01, 2011 2:04 pm
by c4s
max_aigneraigner@web.de wrote:and have a good flush into the next year :)
I think "Happy New Year" is what you want to say. To me this sounds more like being on the toilet. :lol:

Re: Funny christmas bug

Posted: Sat Jan 01, 2011 8:19 pm
by blueznl
Something which also needs to be taken care of... otherwise it will be a new year but not a happy one :-)