#defines with variable # arguments

Juergen Wagner gandalf at csli.STANFORD.EDU
Tue May 17 05:47:49 AEST 1988


To put my five cents into this discussion:

I prefer to use a simple macro like
	# ifdef DEBUG
	#   define DBG	do_debug
	# else !DEBUG
	#   define DBG	if (0) do_debug
	# endif DEBUG
This will expand the lines of the form
	DBG(flag, "sorry, the flag is %d", flag);
into a line which calls my function do_debug only if DEBUG is set. Of course,
do_debug is a function with a variable number of arguments.

I know, there are applications where this is not suffifient, and I know one
can use double parens, ... This posting is a comment and not a dogma!

-- 
Juergen "Gandalf" Wagner,		   gandalf at csli.stanford.edu
Center for the Study of Language and Information (CSLI), Stanford CA



More information about the Comp.unix.wizards mailing list