httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Re: nice try, no cigar
Date Sat, 08 Jun 1996 17:02:31 GMT
Robert S. Thau wrote:
> 
>   I believe he was trying to create a version of an Explain macro that would
>   take printf-style parameters
> 
> Ah.  Yes, that is trickier.  I guess there's the old doubled-parens trick:
> 
>   #ifndef NDEBUG
>   #define EXPLAIN(x) _explain x
>   void _explain (int level, const char* fmt, ...);
>   #else
>   #define EXPLAIN(x) /* nothing */
>   #endif
> 
>   ...
> 
>   EXPLAIN((WARN_LEVEL, "leaky faucet, %f drips/minute", drip_rate));
> 
> but it's ugly, and besides, it doesn't sneak in __LINE__ and __FILE__.
> Hmmm...

You can get line and file in like this:

#define MARK	__LINE__,__FILE
#define EXPLAIN(x)	_explain x
void _explain(int line,const char *file,int level,const char *fmt,...);

...

EXPLAIN((MARK,WARN_LEVEL,...))

Even uglier. But, it does work...

Cheers,

Ben.

> 
> rst

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.

Mime
View raw message