Welcome, Guest. Please login or register.

Author Topic: SAS/C var_arg Macros  (Read 933 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline SidewinderTopic starter

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 241
    • Show only replies by Sidewinder
    • http://www.liquido2.com
SAS/C var_arg Macros
« 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.
Sidewinder
 

Offline Thomas

Re: SAS/C var_arg Macros
« Reply #1 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.)