From fac749d5f8fab2991c3b149b82f168cec194362b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 9 Mar 2017 20:04:26 +0100 Subject: [PATCH] TP 13 exo1: Finish the buildsystem and the directories structure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add include guards to each header file Signed-off-by: Jérôme Benoit --- TP_13/exo1/Makefile | 5 +---- TP_13/exo1/lib/array.h | 5 +++++ TP_13/exo1/lib/io.h | 6 ++++++ TP_13/exo1/lib/macros.h | 30 ++++++++++++++++++++++++++++++ TP_13/exo1/lib/sort.h | 5 +++++ TP_13/exo1/src/exo1.c | 2 ++ 6 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 TP_13/exo1/lib/macros.h diff --git a/TP_13/exo1/Makefile b/TP_13/exo1/Makefile index 8308357..65b7fdc 100644 --- a/TP_13/exo1/Makefile +++ b/TP_13/exo1/Makefile @@ -43,6 +43,7 @@ STRIP_FLAG = -s OPTI_FLAG = -O3 endif +# Puting header files in the source directory is not the purpose of this INCLUDES variable INCLUDES := $(INCLUDES) -I$(SRC_PATH) -I$(LIBRARY_PATH) CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES) LIBCFLAGS := -fPIC $(CFLAGS) @@ -84,10 +85,6 @@ $(BINARY_NAME).static: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a @echo "[LD ] $@" @$(LD) $(CFLAGS) $(STATICLIBLDFLAGS) $^ $(LDLIBS) -o $@ -#$(BINARY_NAME).staticlocal: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).a -# @echo "[LD ] $@" -# @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ - $(BINARY_NAME).dynamic: $(OBJS) $(LIBRARY_PATH)/$(LIBRARY_NAME).so @echo "[LD ] $@" @$(LD) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ diff --git a/TP_13/exo1/lib/array.h b/TP_13/exo1/lib/array.h index e69de29..1f0be27 100644 --- a/TP_13/exo1/lib/array.h +++ b/TP_13/exo1/lib/array.h @@ -0,0 +1,5 @@ +#ifndef ARRAY_H +#define ARRAY_H + + +#endif /* ARRAY_H */ diff --git a/TP_13/exo1/lib/io.h b/TP_13/exo1/lib/io.h index e69de29..56eef23 100644 --- a/TP_13/exo1/lib/io.h +++ b/TP_13/exo1/lib/io.h @@ -0,0 +1,6 @@ +#ifndef IO_H +#define IO_H + + + +#endif /* IO_H */ diff --git a/TP_13/exo1/lib/macros.h b/TP_13/exo1/lib/macros.h new file mode 100644 index 0000000..ab500df --- /dev/null +++ b/TP_13/exo1/lib/macros.h @@ -0,0 +1,30 @@ +/* + * ===================================================================================== + * + * Filename: macros.h + * + * Description: + * + * Version: 1.0 + * Created: 09/03/2017 15:28:46 + * Revision: none + * Compiler: gcc + * + * Author: Jerome Benoit (fraggle), jerome.benoit@piment-noir.org + * Organization: Piment Noir + * + * ===================================================================================== + */ + +#ifndef MACROS_H +#define MACROS_H + +/* definition to expand macro then apply to pragma message */ +#define VALUE_TO_STRING(x) #x +#define VALUE(x) VALUE_TO_STRING(x) +#define VAR_NAME_VALUE(var) #var "=" VALUE(var) + +#define ARRAY_SIZE(arr) ({typeof (arr) arr ## _is_a_pointer __attribute__((unused)) = {}; \ + sizeof(arr) / sizeof(arr[0]);}) + +#endif /* MACROS_H */ diff --git a/TP_13/exo1/lib/sort.h b/TP_13/exo1/lib/sort.h index e69de29..86fd5c4 100644 --- a/TP_13/exo1/lib/sort.h +++ b/TP_13/exo1/lib/sort.h @@ -0,0 +1,5 @@ +#ifndef SORT_H +#define SORT_H + + +#endif /* SORT_H */ diff --git a/TP_13/exo1/src/exo1.c b/TP_13/exo1/src/exo1.c index 06f5f8d..68b3008 100644 --- a/TP_13/exo1/src/exo1.c +++ b/TP_13/exo1/src/exo1.c @@ -1,5 +1,7 @@ #include +#include "macros.h" + int main() { printf("Hello world\n"); -- 2.34.1