From c9e5084687581bb0d090296f894800084684e24b Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 10 Dec 2018 15:49:14 -0500 Subject: [PATCH] added pragmas so I can start erroring on unused functions in C files but ignore the error for headers --- config.h | 3 +-- config.mk | 6 +++--- inc/stdc.h | 5 +++++ inc/vec.h | 5 +++++ inc/x11.h | 5 +++++ src/tide.c | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index bb36a1e..3e71db8 100644 --- a/config.h +++ b/config.h @@ -18,7 +18,7 @@ enum { /* Color Names */ #define CMD_GOTO_TAG "!picktag fetch tags" /* Command used to open file in editor at a given line */ -static char* EditCmd[] = (char*[]){ "tide", "-l", 0, 0, 0 }; +static char* EditCmd[] = { "tide", "-l", 0, 0, 0 }; /* The shell: Filled in with $SHELL. Used to execute commands */ static char* ShellCmd[] = { 0, "-c", 0, 0 }; @@ -132,4 +132,3 @@ Rule* BuiltinRules[] = { #endif #pragma GCC diagnostic pop - diff --git a/config.mk b/config.mk index dde9951..6c80145 100644 --- a/config.mk +++ b/config.mk @@ -1,7 +1,7 @@ # Customize this file to fit your system # number of threads/cores to use -MAKEFLAGS = -j4 +MAKEFLAGS += -j # Install location #PREFIX = $(HOME) @@ -18,9 +18,9 @@ INCS += -I/usr/include/freetype2 # Compiler Setup CC = cc -CFLAGS = -g --std=c99 -MMD $(INCS) +CFLAGS = -g -MMD $(INCS) +CFLAGS += --std=c99 -pedantic CFLAGS += -Wall -Wextra -CFLAGS += -Wno-unused-function CFLAGS += -Werror # Linker Setup diff --git a/inc/stdc.h b/inc/stdc.h index 5ff68d6..d42b1df 100644 --- a/inc/stdc.h +++ b/inc/stdc.h @@ -19,6 +19,9 @@ #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" + static char* strmcat(char* first, ...) { va_list args; /* calculate the length of the final string */ @@ -198,3 +201,5 @@ static inline char* _getopt_(int* p_argc, char*** p_argv) { #define max(x,y) \ ((x) > (y) ? (x) : (y)) #endif + +#pragma GCC diagnostic pop diff --git a/inc/vec.h b/inc/vec.h index c7b6113..ca85701 100644 --- a/inc/vec.h +++ b/inc/vec.h @@ -12,6 +12,9 @@ #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" + typedef struct { size_t elem_count; size_t elem_size; @@ -117,4 +120,6 @@ static void vec_sort(vec_t* vec, int (*cmpfn)(const void*,const void*)) { qsort(vec->elem_buffer, vec->elem_count, vec->elem_size, cmpfn); } +#pragma GCC diagnostic pop + #endif /* VEC_H */ diff --git a/inc/x11.h b/inc/x11.h index 87ed333..9ea4835 100644 --- a/inc/x11.h +++ b/inc/x11.h @@ -6,6 +6,9 @@ #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" + typedef struct XConf { int fd, screen, width, height; Window root; @@ -87,3 +90,5 @@ static void x11_event_loop(XConf* x) { for (int status; waitpid(-1, &status, WNOHANG) > 0;); } } + +#pragma GCC diagnostic pop diff --git a/src/tide.c b/src/tide.c index ab66529..d9b6843 100644 --- a/src/tide.c +++ b/src/tide.c @@ -13,7 +13,7 @@ typedef struct { } Tag; char* ARGV0; -static Tag Builtins[]; +static Tag Builtins[16]; /* Tag/Cmd Execution ******************************************************************************/ @@ -412,7 +412,7 @@ static void lnexec(char* cmd) { /* Main Routine ******************************************************************************/ -static Tag Builtins[] = { +static Tag Builtins[16] = { { .tag = "Cut", .action = cut }, { .tag = "Copy", .action = copy }, { .tag = "Del", .action = quit }, -- 2.52.0