feat(09): adding the debug mode to ex00
This commit is contained in:
parent
5ddecf46b7
commit
c1dcf45198
3 changed files with 19 additions and 14 deletions
|
|
@ -6,12 +6,16 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/08 12:18:18 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
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
#define DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/12 11:05:05 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
|
CXXFLAGS = -Werror -Wextra -Wall -std=c++98
|
||||||
# Flags to have the dependences (can be removed for correction)
|
# Flags to have the dependences (can be removed for correction)
|
||||||
# Flags to have the debug (can be removed for correction)
|
# Flags to have the debug (can be removed for correction)
|
||||||
DEBUG = -g3
|
# DEBUG = -g3
|
||||||
# DEBUG += -fsanitize=address
|
# DEBUG += -fsanitize=address
|
||||||
CXXFLAGS += $(DEBUG)
|
CXXFLAGS += $(DEBUG)
|
||||||
|
|
||||||
|
|
@ -36,10 +36,6 @@ INC_DIR =
|
||||||
|
|
||||||
CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP
|
CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP
|
||||||
|
|
||||||
# Flags to have the dependences (can be removed for correction)
|
|
||||||
# DEBUG = -g3
|
|
||||||
# CPPFLAGS += $(DEBUG)
|
|
||||||
|
|
||||||
# Objects
|
# Objects
|
||||||
OBJDIRNAME = ./build
|
OBJDIRNAME = ./build
|
||||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o))
|
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o))
|
||||||
|
|
@ -83,13 +79,13 @@ re: header fclean all
|
||||||
$(NAME): $(OBJ)
|
$(NAME): $(OBJ)
|
||||||
@mkdir -p $(OBJDIRNAME)
|
@mkdir -p $(OBJDIRNAME)
|
||||||
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
||||||
@$(CXX) $(CXXFLAGS) -o $(NAME) $(OBJ)
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(NAME) $(OBJ)
|
||||||
|
|
||||||
# Creating the objects
|
# Creating the objects
|
||||||
$(OBJDIRNAME)/%.o: %.cpp
|
$(OBJDIRNAME)/%.o: %.cpp
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||||
@$(CXX) $(CXXFLAGS) -o $@ -c $<
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
header:
|
header:
|
||||||
|
|
@ -107,6 +103,9 @@ header:
|
||||||
@printf '$(GOLD) ****** $(END)\n'
|
@printf '$(GOLD) ****** $(END)\n'
|
||||||
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
||||||
|
|
||||||
|
debug: CPPFLAGS += -D DEBUG=1
|
||||||
|
debug: re
|
||||||
|
|
||||||
# Footer
|
# Footer
|
||||||
footer:
|
footer:
|
||||||
@printf "\n"
|
@printf "\n"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/08 12:15:32 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<std::string, float> get_db() {
|
||||||
return to_ret;
|
return to_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
if (DEBUG)
|
||||||
|
std::cout << CLR_MAGENTA << "Warning: DEBUG MODE is enable" << CLR_RESET << std::endl;
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
std::cerr << CLR_RED << "Usage: " << argv[0] << " <filename>" << CLR_RESET << std::endl;
|
std::cerr << CLR_RED << "Usage: " << argv[0] << " <filename>" << CLR_RESET << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
@ -313,9 +313,11 @@ int main(int argc, char *argv[]) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
std::map<size_t, value> user_db = parse_input(argv[1]);
|
std::map<size_t, value> user_db = parse_input(argv[1]);
|
||||||
// _debug_print_input(user_db);
|
if (DEBUG)
|
||||||
|
_debug_print_input(user_db);
|
||||||
std::map<std::string, float> value_db = get_db();
|
std::map<std::string, float> value_db = get_db();
|
||||||
// _debug_print_db(value_db);
|
if (DEBUG)
|
||||||
|
_debug_print_db(value_db);
|
||||||
print_result(user_db, value_db);
|
print_result(user_db, value_db);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue