Skip to content

Instantly share code, notes, and snippets.

@shengyu7697
shengyu7697 / debug.h
Last active March 18, 2018 03:13
debug print
#define DEBUG 4
#if defined(DEBUG)
#if DEBUG >= 4 // filename:function:line
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, "[DEBUG] %s:%s():%d " fmt, \
__FILE__, __func__, __LINE__, ##__VA_ARGS__)
#elif DEBUG >= 3 // filename:function
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, "[DEBUG] %s:%s() " fmt, \
__FILE__, __func__, ##__VA_ARGS__)
#elif DEBUG >= 2 // filename:line
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, "[DEBUG] %s:%d " fmt, \