From 658c6acc5900678d8f2a4a31acb407b027c90f4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 21 Aug 2017 14:46:50 +0200 Subject: [PATCH] Implement some basic debug printing function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- Makefile | 2 +- lib/debug.c | 11 +++++++---- lib/debug.h | 7 +++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2a3ae22..fd4ca9a 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,7 @@ endif # Putting header files in the source directory is not the purpose of this INCLUDES_PATH variable INCLUDES_PATH := $(INCLUDES_PATH) -I$(LIBRARY_PATH) -CFLAGS := $(CFLAGS) $(CFLAGS_LTO) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES_PATH) +CFLAGS := -DBUILD_TYPE=$(BUILD_TYPE) $(CFLAGS) $(CFLAGS_LTO) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES_PATH) LIBCFLAGS := -fPIC $(CFLAGS) LDFLAGS := $(LDFLAGS) $(LDFLAGS_LTO) $(LDFLAGS_GOLD) $(STRIP_FLAG) LIBLDFLAGS := $(SHLIBLDFLAG) $(LDFLAGS) diff --git a/lib/debug.c b/lib/debug.c index 6532079..e00ce9f 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -19,7 +19,6 @@ #include #include "othello.h" -#include "constants.h" #include "debug.h" void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]) { @@ -33,6 +32,10 @@ void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][b } } -/* void dbg_mvprintv(int y, int x, ) { - -} */ +#if BUILD_TYPE == debug +void dbg_mvprintv(int y, int x, char* debug_text) { + mvprintw(y, x, debug_text); +} +#else +void dbg_mvprintv(int y, int x, char* debug_text) { } +#endif diff --git a/lib/debug.h b/lib/debug.h index 8d4d3b9..e87809d 100644 --- a/lib/debug.h +++ b/lib/debug.h @@ -16,6 +16,13 @@ * ===================================================================================== */ +#ifndef DEBUG_H +#define DEBUG_H + #include +#include "constants.h" + void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]); + +#endif /* DEBUG_H */ -- 2.34.1