Disappearing function call

Frank Adams franka at mmintl.UUCP
Thu Oct 9 06:10:14 AEST 1986


In article <3731 at umcp-cs.UUCP> chris at umcp-cs.UUCP writes:
>The problem: to include debug calls, with variable argument lists,
>such that they may be conditionally compiled (a la #if), but without
>cluttering the source with `#ifdef'.
>
>2:	#ifdef DEBUG
>	#define	debug
>	#else
>	#define debug debug_
>	#endif
>	...
>		debug("foo(%s, %d)", foostring, foovalue);
>		...
	(the #defines here should be reversed)
>Problems: [...]
>Other compilers generate code and/or data even when DEBUG is turned
>off, since this preprocesses to
>
>		("foo(%s, %d)", foostring, foovalue);

This problem is not totally dependent on the quality of the compiler.  If
any of the arguments to the debug_ function involves a function call, the
compiler *must* generate code for it.  E.g.,

	debug("x=%d, sin(x)=%d", x, sin(x));

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108



More information about the Comp.lang.c mailing list