C DEBUG macro (stop me if you"ve heard this)

utzoo!decvax!harpo!floyd!whuxlb!eisx!npoiv!houxm!houxz!hocda!spanky!burl!duke!mcnc!unc!tim utzoo!decvax!harpo!floyd!whuxlb!eisx!npoiv!houxm!houxz!hocda!spanky!burl!duke!mcnc!unc!tim
Fri Apr 29 00:16:29 AEST 1983


There was an error in my previous article. Sorry.

The DEBUG statements can only be of the form DEBUG(msg); .
The reason is that the C macro processor can only cope with
fixed-length argument lists, for some silly reason. If you
want to have other arguments, then you will have to have
each argument list be the same size. Supplying NULL arguments
as padding to your DEBUGs should work, but may not on your
system (due to the fact that printf behavior when given a
weird argument list is undefined). The only safe way is to
use only single-argument printf's, or to have all your printf
format strings accept the same number of arguments.

Again, sorry for any inconvenience caused. The DEBUG macro
I gave is still quite useful, despite its limitations.

Tim Maroney



More information about the Comp.lang.c mailing list