42_Scale

a small software to create and edit 42 (.yaml) scale files easily
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/42_Scale

commit da6ad8307b2008fada5d558265667da7ef401525
parent 908e9a98a2aaf738c00e56ddada46d5587fa0ce8
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 22 Apr 2016 17:20:27 +0200

Add(Files): ->:

Add Makefile
Add base main.c, with advanced error handling, w/ backtrace
Add nuklear submodule to the git

Diffstat:
A.gitmodules | 3+++
AMakefile | 26++++++++++++++++++++++++++
Ainc/nuklear | 1+
Ainc/scale.h | 16++++++++++++++++
Asrcs/helpers.c | 14++++++++++++++
Asrcs/main.c | 8++++++++
6 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "inc/nuklear"] + path = inc/nuklear + url = https://github.com/vurtun/nuklear.git diff --git a/Makefile b/Makefile @@ -0,0 +1,26 @@ +NAME = 42_scale +CC = gcc +CFLAGS = -Wall -Wextra -Werror -g -O2 +LIBS = -lglfw3 -framework OpenGL -lm -lGLEW +LIBS_DIR = -L ~/.brew/lib +INCS = -I inc/ -I inc/nuklear/ -I ~/.brew/include +SRCS = $(wildcard srcs/*.c) +OBJS = $(SRCS:%.c=%.o) + +%.o: %.c + $(CC) $(CFLAGS) $(INCS) -o $@ -c $^ + +all: $(NAME) + +$(NAME): $(OBJS) + $(CC) $(CFLAGS) $(LIBS_DIR) $(LIBS) $(OBJS) -o $(NAME) + +clean: + rm -f $(OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all + +.PHONY: clean fclean re diff --git a/inc/nuklear b/inc/nuklear @@ -0,0 +1 @@ +Subproject commit bc8db2e3f3b9f67dcb7cf5a87e7cecd182fd26a2 diff --git a/inc/scale.h b/inc/scale.h @@ -0,0 +1,16 @@ +#ifndef __SCALE__ +# define __SCALE__ + +# include <nuklear.h> +# include <stdlib.h> +# include <stdio.h> +# include <stddef.h> +# include <execinfo.h> + +# define ERROR(str) printf("\033[1;31mFATAL ERROR:\033[0m 42_scale must stop. \n\033[0;32m> \033[0m %s\n", str); print_trace(); _exit(1); + +/* HELPERS (helpers.c) */ + +void print_trace(void); + +#endif diff --git a/srcs/helpers.c b/srcs/helpers.c @@ -0,0 +1,14 @@ +# include <scale.h> + +void print_trace(void) { + void *array[10]; + size_t size; + char **strings; + + size = backtrace (array, 10); + strings = backtrace_symbols (array, size); + printf ("\033[0;32m> \033[0m Printing backtrace ...\n"); + for (size_t i = 0; i < size; i++) + printf ("%s\n", strings[i]); + free (strings); +} diff --git a/srcs/main.c b/srcs/main.c @@ -0,0 +1,8 @@ +# include <scale.h> + +int main(int ac, char **av) { + if (ac == 1 || !av) { + ERROR("Need an argument !"); + } + return 0; +}