[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: kDebug idea
From:       Cristian Tibirna <tibirna () kde ! org>
Date:       2002-03-31 23:12:55
[Download RAW message or body]

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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic