Amiga.org

Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: Sidewinder on March 19, 2010, 04:22:47 PM

Title: SAS/C var_arg Macros
Post by: Sidewinder on March 19, 2010, 04:22:47 PM
I'm attempting to create a debug macro in SAS/C.  The C99 code would be something like:

#define DEBUG_PRINT(format, ...)   printf(format, ...)

But since SAS/C isn't C99 that won't work.  So I tried:

#define DEBUG_PRINT(x)  printf x

Which also faild to work, saying that there are too many arguments when I do something like:

DEBUG_PRINT("%s\n", "hello");

Anyway, what is the proper way to define var_args macros in SAS/C?

Thanks.
Title: Re: SAS/C var_arg Macros
Post by: Thomas on March 19, 2010, 04:29:08 PM
I've seen people doing

#define D(x) x

and

D(printf ("%s\n","Hello"); )

To remove debug output change the macro to

#define D(x) /* no debug */

(not sure if I remembered everything correctly and if it works in SAS/C, but it avoids varargs macros.)