GLBasic forum

Codesnippets => Inline / 3rd party => Topic started by: bigsofty on 2010-Feb-24

Title: iPhone DEBUG()
Post by: bigsofty on 2010-Feb-24
Simple, replace all your DEBUG() with iDEBUG() and all DEBUG command output will go to the XCode Console window (Under the "Run" menu). When running your program in Windows it will redirect DEBUG back to the normal console output.

Very simple but handy for seeing some output on the running machine.

Code: GLBasic [Select]
// iPhone DEBUG

        FUNCTION iDEBUG: debug$
                ?IFDEF WIN32
                        DEBUG debug$
                ?ELSE
                        INLINE
                        STDOUT(debug_Str);
                        ENDINLINE
                ?ENDIF
        ENDFUNCTION

Use...

Code: GLBasic [Select]
iDEBUG("This is a test!\n")

... it will work on all platforms.


Some Notes:

Thanks to Trucidare for the heads up on STDOUT.

Actually this will send DEBUG output to the GDB Console on any other platform than Windows, handy for Linux/Mac etc...

Not sure how this would perform is STDOUT has been redirected, say for a console program?

I wanted to wrap it all using "?IFDEF GLB_DEBUG" so that I could use the little debug switch, to turn iPhone console output on and off but it seems to be only defined for debugging in WIN32. Maybe Gernot could add this?

Until then you can do it manually if you want all DEBUG output off by wrapping it in your own preprocesser variable, "MY_DEBUG" for example.



Title: Re: iPhone DEBUG()
Post by: MikeHart on 2010-Feb-24
Regarding IPhone, did you check the xcode debugger with the regular debug command?
Title: Re: iPhone DEBUG()
Post by: bigsofty on 2010-Feb-24
Yes, the normal GLB DEBUG command does not output anything to the console, even with the XCode debugger on.
Title: Re: iPhone DEBUG()
Post by: MikeHart on 2010-Feb-24
What? Then I wonder why I got debug output there.
Title: Re: iPhone DEBUG()
Post by: Kitty Hello on 2010-Feb-24
stdout also works on windows:

Code: GLBasic [Select]
IMPORT  void __AllocConsole()
__AllocConsole()