用法:如c函数printf
#define DBG_PRINT(fmt,...) \
do \
{ \
FILE * ___fp = fopen (DEBUG_FILENAME, "a+"); \
if (___fp) \
{ \
fprintf (___fp, "[%s:%d:%s] " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
fflush (___fp); \
fclose (___fp); \
} \
}while(0)
举例:
DBG_PRINT ("This is a test: a = %d\n", a);