Variable arguments in macros

Brad Brown bradb at ai.toronto.edu
Tue Apr 18 06:33:37 AEST 1989


I've been trying to find a way to have macros with variable numbers of
arguments in ANSI C, and I don't think it can be done.  I'm hoping that
I'm wrong and that someone can tell me how to do it.

What I'd like to do is have a header file with a macro similar to 

	#define trace(s)  { fprintf( stderr, s ); }

and then call it like

	trace( "Entering zot(), arg is %d", arg );

or

	trace( "I'm here." );

If I could get the whole argument list to bind to s then everything would 
work.  I can't do that, can I?

Thanks for your help!

					(-:  Brad Brown  :-)
					bradb at ai.toronto.edu



More information about the Comp.std.c mailing list