From c1dcf45198d0509ea1922a4b6665295302f1c398 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 2 May 2025 15:22:51 +0200 Subject: [PATCH] feat(09): adding the debug mode to ex00 --- cpp09/ex00/BitcoinExchange.hpp | 6 +++++- cpp09/ex00/Makefile | 15 +++++++-------- cpp09/ex00/main.cpp | 12 +++++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/cpp09/ex00/BitcoinExchange.hpp b/cpp09/ex00/BitcoinExchange.hpp index 5cfc675..95c914c 100644 --- a/cpp09/ex00/BitcoinExchange.hpp +++ b/cpp09/ex00/BitcoinExchange.hpp @@ -6,12 +6,16 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:18:18 by rparodi #+# #+# */ -/* Updated: 2025/04/13 16:19:47 by rparodi ### ########.fr */ +/* Updated: 2025/05/02 15:19:32 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once +#ifndef DEBUG +#define DEBUG 0 +#endif + #include #include #include diff --git a/cpp09/ex00/Makefile b/cpp09/ex00/Makefile index f01ec46..f27eb28 100644 --- a/cpp09/ex00/Makefile +++ b/cpp09/ex00/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/04/13 15:38:33 by rparodi ### ########.fr # +# Updated: 2025/05/02 15:21:09 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -24,7 +24,7 @@ RM = rm -rf CXXFLAGS = -Werror -Wextra -Wall -std=c++98 # Flags to have the dependences (can be removed for correction) # Flags to have the debug (can be removed for correction) -DEBUG = -g3 +# DEBUG = -g3 # DEBUG += -fsanitize=address CXXFLAGS += $(DEBUG) @@ -36,10 +36,6 @@ INC_DIR = CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP -# Flags to have the dependences (can be removed for correction) -# DEBUG = -g3 -# CPPFLAGS += $(DEBUG) - # Objects OBJDIRNAME = ./build OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o)) @@ -83,13 +79,13 @@ re: header fclean all $(NAME): $(OBJ) @mkdir -p $(OBJDIRNAME) @printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n' - @$(CXX) $(CXXFLAGS) -o $(NAME) $(OBJ) + @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(NAME) $(OBJ) # Creating the objects $(OBJDIRNAME)/%.o: %.cpp @mkdir -p $(dir $@) @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' - @$(CXX) $(CXXFLAGS) -o $@ -c $< + @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< # Header header: @@ -107,6 +103,9 @@ header: @printf '$(GOLD) ****** $(END)\n' @printf '$(GREY) Made by rparodi$(END)\n\n' +debug: CPPFLAGS += -D DEBUG=1 +debug: re + # Footer footer: @printf "\n" diff --git a/cpp09/ex00/main.cpp b/cpp09/ex00/main.cpp index 38d0eec..1982e94 100644 --- a/cpp09/ex00/main.cpp +++ b/cpp09/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */ -/* Updated: 2025/04/16 18:19:29 by rparodi ### ########.fr */ +/* Updated: 2025/05/02 15:22:16 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -289,9 +289,9 @@ std::map get_db() { return to_ret; } - - int main(int argc, char *argv[]) { + if (DEBUG) + std::cout << CLR_MAGENTA << "Warning: DEBUG MODE is enable" << CLR_RESET << std::endl; if (argc != 2) { std::cerr << CLR_RED << "Usage: " << argv[0] << " " << CLR_RESET << std::endl; exit(1); @@ -313,9 +313,11 @@ int main(int argc, char *argv[]) { exit(1); } std::map user_db = parse_input(argv[1]); - // _debug_print_input(user_db); + if (DEBUG) + _debug_print_input(user_db); std::map value_db = get_db(); - // _debug_print_db(value_db); + if (DEBUG) + _debug_print_db(value_db); print_result(user_db, value_db); }