LIBRARY_NAME:=lib$(BINARY_NAME)
LIBRARY_PATH:=lib
LDLIBS:=-l$(BINARY_NAME) -lncurses -ltinfo
-BUILD_TYPE:=debug
-#BUILD_TYPE:=release
+#BUILD_TYPE:=debug
+BUILD_TYPE:=release
# ====================================
# DO NOT CHANGE STUFF BEYOND THIS LINE
ifeq ($(BUILD_TYPE),debug)
BUILDDIR := .build/debug
DEBUG_FLAG = -g
+DEBUG = 1
STRIP_FLAG =
OPTI_FLAG = -O0
LTO_SUPPORT = yes
else
BUILDDIR := .build/release
DEBUG_FLAG =
+DEBUG = 0
STRIP_FLAG = -s
OPTI_FLAG = -O3
LTO_SUPPORT = yes
# Putting header files in the source directory is not the purpose of this INCLUDES_PATH variable
INCLUDES_PATH := $(INCLUDES_PATH) -I$(LIBRARY_PATH)
-CFLAGS := -DBUILD_TYPE=$(BUILD_TYPE) $(CFLAGS) $(CFLAGS_LTO) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES_PATH)
+CFLAGS := -DDEBUG=$(DEBUG) $(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)
#include "othello.h"
#include "debug.h"
-#if BUILD_TYPE == debug
-void dbg_mvprintw(int y, int x, const char* debug_text, ...) {
- va_list func_args;
- char debug_msg[256];
-
- snprintf(debug_msg, sizeof(debug_msg), "%s%s", "DEBUG: ", debug_text);
- va_start(func_args, debug_text);
- mvprintw(y, x, debug_msg, func_args);
- va_end(func_args);
-}
-#else
-void dbg_mvprintw(int y, int x, const char* debug_text, ...);
-#endif
-
+#if DEBUG
void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]) {
for (int i = 1; i <= board_size; i++) {
- dbg_mvprintw(base_y + i, base_x, "%d", i);
+ mvprintw(base_y + i, base_x, "%d", i);
for (int j = 1; j <= board_size; j++) {
- dbg_mvprintw(base_y, base_x + j, "%d", j);
- dbg_mvprintw(base_y + i, base_x + j, "%d", get_box_value(i, j, pawn_array));
+ mvprintw(base_y, base_x + j, "%d", j);
+ mvprintw(base_y + i, base_x + j, "%d", get_box_value(i, j, pawn_array));
}
}
}
+#else
+void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]) { }
+#endif /* DEBUG */
#include "constants.h"
-void dbg_mvprintw(int y, int x, const char* debug_text, ...);
+#if DEBUG
+#define dbg_mvprintw(...) mvprintw(__VA_ARGS__)
+#else
+#define dbg_mvprintw(...) { }
+#endif /* DEBUG */
+
void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]);
#endif /* DEBUG_H */
mvprintw(center_y, center_x - 42/2 - snprintf(NULL, 0, score_msg, "noirs", nb_black) - 2, score_msg, "noirs", nb_black);
mvprintw(center_y, center_x + 42/2 + 2, score_msg, "blancs", nb_white);
- //display_array(1, 1, pawns);
+ display_array(1, 1, pawns);
int y;
char x_char;
unsigned int nb_pawns_reversed = 0;
do {
y = 0;
- x_char = "";
+ x_char = (char)"";
const char* prompt_msg = "Prochain pion ? (ligne colonne - chiffre lettre):";
int prmt_rt = prompt_values(stdscr, center_y + 26/2 + 1, (center_x - strlen(prompt_msg)/2), prompt_msg, &y, &x_char);
int x = map_col_letter_to_index(x_char);