GLBasic forum

Codesnippets => Inline / 3rd party => Topic started by: bigsofty on 2011-Aug-22

Title: Cross Platform Debug Output
Post by: bigsofty on 2011-Aug-22
Small update (better late than never Gernot! :P).

Cross platform debug text output snippet, on iPhone it sends the text to the XCode console debug window for example.

Call InitDebug() at the beginning of your code.

P.S. By using DEBUG() and myDEBUG(), you can output to two separate windows on WIN32, not sure if that's of any use though.

Code (glbasic) Select
// ------------------------------------------ //
//! Initialise Console Window on WIN32
// \param - None
// \preturn - Nothing
// ------------------------------------------ //
FUNCTION InitDebug:
?IFDEF WIN32
IMPORT void __AllocConsole()
__AllocConsole()
?ENDIF
ENDFUNCTION


// ------------------------------------------ //
//! Cross-Platform Debug Text
// \param - None
// \preturn - Nothing
// ------------------------------------------ //
FUNCTION myDEBUG: debug$
    INLINE
         STDOUT(debug_Str);
    ENDINLINE
ENDFUNCTION

Title: Re: Cross Platform Debug Output
Post by: Kitty Hello on 2011-Aug-22
why inline around stdout?
Title: Re: Cross Platform Debug Output
Post by: bigsofty on 2011-Aug-22
I honestly cant remember, there was a reason... maybe it pre-dates STDOUT as a command?  :S

The 2nd console window is still handy I suppose though.

P.S. I wrapped the STDOUT so that I could do a quick search and replace for "myDEBUG" to "//myDEBUG" for the final production compilation. Avoiding a mass of extra preprocessing directives for debug mode only or any unnecessary sub calls.