From kde-core-devel Sun Mar 31 23:12:55 2002 From: Cristian Tibirna Date: Sun, 31 Mar 2002 23:12:55 +0000 To: kde-core-devel Subject: Re: kDebug idea X-MARC-Message: https://marc.info/?l=kde-core-devel&m=101761651927307 On Sunday, 31 March 2002 12:35, Simon Hausmann wrote: > Hi, > > There are quite a few places where people use code like this: > > // #define DEBUG_FOO > > ... > > #if DEBUG_FOO > kdDebug() << "bleh" << endl; > #endif > [cut nice solution] > What do you think? At my work we use macros (and I grew to like this way, although I was used to think of preprocessor abuse like of something religiously sinnful :-). The advantage of that is that it can be completely outcompiled in optimization mode, without the ugliness (and line number increase) of the #if prepro directives. Something like: _KDE_DEBUG("bleh\n"); which is resumed to a printf("bleh\n"); in devel mode and to a ; in optim. mode. Still, we mostly use this for assertions, preconditions and postconditions (contract driven programming, yes) and only for programmer-side errors, not for user debug output. Anyways, I realize what I say is quite different, but it's interesting to mention, I believe (and there is something better to our debugging mechanisms, namely a rather sofisticated memory management checking, which makes tools like mmalloc or electric fence or valgrind have much less use), but that would be real overkill for KDE's huge code. CT