一只名叫tom的猫
对于可移植的(ISO C 90)实现,可以使用双括号,如下所示;#include <stdio.h>#include <stdarg.h>#ifndef NDEBUG# define debug_print(msg) stderr_printf msg#else#
define debug_print(msg) (void)0#endifvoidstderr_printf(const char *fmt, ...){
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);}intmain(int argc, char *argv[]){
debug_print(("argv[0] is %s, argc is %d\n", argv[0], argc));
return 0;}或者(Hackish,不推荐)#include <stdio.h>#define _ ,#ifndef NDEBUG# define debug_print(msg) fprintf(stderr, msg)#else#
define debug_print(msg) (void)0#endifintmain(int argc, char *argv[]){
debug_print("argv[0] is %s, argc is %d"_ argv[0] _ argc);
return 0;}