From: Lukas Jiriste Date: Thu, 24 Oct 2024 13:14:43 +0000 (+0200) Subject: Add main.cpp and Makefile or ex03 X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=720e5c9cdf5b3b8f7a1ac60a8d285f8c5f7dbcb5;p=42%2FCPP_Module_02 Add main.cpp and Makefile or ex03 --- diff --git a/ex03/Makefile b/ex03/Makefile new file mode 100644 index 0000000..3d78302 --- /dev/null +++ b/ex03/Makefile @@ -0,0 +1,55 @@ +CC := c++ +CFLAGS = -std=c++98 -Wall -Wextra -Werror -Wpedantic + +ifneq ("$(wildcard .debug)","") + CFLAGS += -g +endif + +RM := rm -f + +INCDIR := inc +INCDIR += $(addsuffix /inc, $(SUBPROJECTS)); +ifneq ($(INCLUDE),) + INCLUDE := $(addprefix -I, $(INCDIR)) +endif + +SRCDIR := . + +SOURCES := main.cpp \ + Fixed.cpp \ + Point.cpp \ + bsp.cpp \ + +SOURCES := $(addprefix $(SRCDIR)/, $(SOURCES)) + +OBJECTS := $(SOURCES:.cpp=.o) + +NAME := fixed + +all : $(NAME) + +debug : .debug + $(MAKE) all + +nodebug : + $(RM) .debug + $(MAKE) re + +.% : + $(MAKE) fclean + touch $@ + +$(NAME) : $(OBJECTS) + $(CC) $(CFLAGS) -o $@ $^ $(LINKS) + +%.o : %.cpp + $(CC) $(CFLAGS) -o $@ -c $< $(INCLUDE) + +clean : + $(RM) $(OBJECTS) + +fclean : clean + $(RM) $(NAME) + +re : fclean + $(MAKE) all diff --git a/ex03/main.cpp b/ex03/main.cpp new file mode 100644 index 0000000..d3dbef9 --- /dev/null +++ b/ex03/main.cpp @@ -0,0 +1,26 @@ +#include "Fixed.h" +#include "Point.h" +#include + +int main() +{ + Point a(0, 0); + Point b(1, 0); + Point c(0, 1); + Point d(0.75f, 0.75f); + Point e(1, 1); + + std::cout << d << " lies inside triangle " + << a << ", " << b << ", " << e + << ": " << std::boolalpha << bsp(a, b, e, d) << ".\n"; + std::cout << d << " lies inside triangle " + << a << ", " << e << ", " << c + << ": " << std::boolalpha << bsp(a, e, c, d) << ".\n"; + std::cout << d << " lies inside triangle " + << e << ", " << b << ", " << c + << ": " << std::boolalpha << bsp(e, b, c, d) << ".\n"; + std::cout << d << " lies inside triangle " + << a << ", " << b << ", " << c + << ": " << std::boolalpha << bsp(a, b, c, d) << ".\n"; + return (0); +}