passing all writefln arguments

Bill Baxter dnewsgroup at
Thu Mar 20 16:27:48 PDT 2008

Saaa wrote:
> Thanks,
> As I think that changing a variable is easier than changing the compiler 
> line I went with:
> const bool DEBUGG=false;
> static if (DEBUGG == true) {
>  alias writefln dWritefln;
> }
> else {
>  void dWritefln(...) {}
> }

I think you can set debug versions inside a file too.  That way you can 
have the best of both worlds.  Turn it on from the command line, or by 
modifying the file.

debug = DEBUGG;

debug(DEBUGG) {
  alias writefln dWritefln;
else {
  void dWritefln(...) {}

... at least that works with 'version'.  Not sure if it works with debug 
too.  (If it doesn't I'll file a bug about the inconsistency with 

> Will dWritefln(..){} compile to 'nothing'?
 > I mean, will calling dWritefln when DEBUGG=false take no cpu tick 
(does the
 > compiler see that it does nothing)?

Yes.  See thread entitled "debug()" over in digitalmars.D. digitalmars.D:66826 digitalmars.D:66827

But that may only be with -inline.  Not sure what flags Jarrett used 
when he ran the test.


More information about the Digitalmars-d-learn mailing list