[linux-elitists] Stupid C tricks

Greg KH greg@kroah.com
Sat Aug 28 16:46:34 PDT 2004


On Sat, Aug 28, 2004 at 06:33:14PM -0500, Brian McGroarty wrote:
> On Fri, Aug 27, 2004 at 09:56:51PM -0700, Greg KH wrote:
> > 
> > Ick, what about something like what the kernel does in places:
> > 
> > #ifdef DEBUG
> > #define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg)
> > #else
> > #define dbg(format, arg...) do {} while (0)
> > #endif
> 
> Being pedantic...
> 
> Instead of:
> do {} while (0)
> 
> Try:
> (void)0
> 
> That generates less junk code in non-optimized builds.

Are you sure?  gcc generates the same code (nothing) the last time I
looked.

thanks,

greg k-h



More information about the linux-elitists mailing list