Skip to content

Commit

Permalink
[debug] add DEBUG_PRINT example
Browse files Browse the repository at this point in the history
  • Loading branch information
luhuadong committed Oct 8, 2022
1 parent 55b838b commit 98f2d42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions debug/debug_print.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>

static int debug = 1; /* enable this to printf */

#define DEBUG_PRINT(fmt, args...) \
do { if(debug) \
printf(fmt, ## args); \
} while(0)

int main(void)
{
DEBUG_PRINT("Hello, World!\n");
return 0;
}
5 changes: 5 additions & 0 deletions debug/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
gcc debug_print.c -o debug_print

clean:
rm debug_print

0 comments on commit 98f2d42

Please sign in to comment.