Passing Variable Numbers of Arguments

Gerrit Brouwer gerrit at xelion.UUCP
Thu Feb 14 00:39:29 AEST 1991


sanders at peyote.cactus.org (Tony Sanders) writes:

>In article <1991Feb11.225815.5875 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:

>So I do this:

>#ifdef NODEBUG
>#define DP(level) if (0)	/* I hope the optimizer gets rid of this */
>#else
>extern DebugPrint(char *,...);
>#define DP(level) if (debug&level) DebugPrint
>#endif
>DP(1)("this fmt string %s\n","sucks rocks");


>Any better ideas???

I do this:

#ifdef	DO_DEBUG
#define	PRINT(ARGUMENTS) DebugPrint ARGUMENTS
#else
#define	PRINT(ARGUMENTS) DebugPrint ARGUMENTS
#endif	DO_DEBUG

PRINT(("any number of arguments allowed: %s %d %f\n", "string", 4, 3.14));


-- 
Gerrit Brouwer                     domain : gerrit at xelion.UUCP
XELION BV                          uucp   : uunet!mcsun!hp4nl!xelion!gerrit
Postbus 88                         phone  : +31 15 622121
2600 AB Delft, The Netherlands     fax    : +31 15 621760



More information about the Comp.lang.c mailing list