Error Message useless

Mike vertex at gmx.at
Mon May 12 13:36:40 PDT 2008


On Mon, 12 May 2008 00:22:39 +0200, Tower Ty <tytower at hotmail.com> wrote:

> Can you explain the debug{} a bit more please  Mike . What does that  
> look like and how is it used?

It's code that only gets compiled in a debug build.

Here's roughly what I do:

debug
{
     alias Stdout dbg;
}

Later on I use Stdout for every normal output, but dbg for temporary debug  
messages:

<example>

Stdout("Initializing warp drive ...").newline; // this should be in the  
console in debug and release mode

WarpEngine.prepareUnipolarMatrixPhalanxThingie(unipolar);
dbg("first call ok, foo = ")(WarpEngine.foo).newline; // this should be  
removed before release

WarpEngine.resetWarpParameterFieldConstants(1, 2, 1701);
dbg("second call ok, bar = ")(WarpEngine.bar).newline;

WarpEngine.initializeWarpNacelles(BOTH);
dbg("third call ok, baz = ")(WarpEngine.baz).newline;

WarpEngine.removeTribbles(all);
dbg("fourth call ok, now engaging").newline;

WarpEngine.engage();

Stdout("Warp drive ready.").newline;

</example>

Those dbg Stdouts should be removed in a release build. But every now and  
then you forget to remove one and it ends up in production. So if you now  
compile this with the -release flag, the alias never gets defined and  
every dbg call still in there yields a syntax error.

-Mike

PS: I'm NOT a Star Trek fan :)

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list