Skip to content

Commit

Permalink
build: add strict mode to gcc flags
Browse files Browse the repository at this point in the history
  • Loading branch information
exbotanical committed Jan 4, 2025
1 parent 25ec7f0 commit e276ff2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
example
.vscode
obj
test
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@ OBJ := $(addprefix obj/, $(notdir $(SRC:.c=.o)) $(notdir $(DEPS:.c=.

INCLUDES := -I$(INCDIR) -I$(DEPSDIR) -I$(SRCDIR)
LIBS := -lm
STRICT := -Wall -Werror -Wextra -Wno-missing-field-initializers \
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \
-Wno-unused-parameter -Wno-unused-function -Wno-unused-value \
-pedantic
CFLAGS := -Wall -Wextra -pedantic -std=c17 $(INCLUDES)

$(DYNAMIC_TARGET): CFLAGS += -shared
$(DYNAMIC_TARGET): $(OBJ)
$(CC) $(CFLAGS) $^ $(LIBS) -o $@
$(CC) $(CFLAGS) $(STRICT) $^ $(LIBS) -o $@

$(STATIC_TARGET): $(OBJ)
$(AR) rcs $@ $^

obj/%.o: $(SRCDIR)/%.c $(INCDIR)/$(LIBNAME).h | obj
$(CC) $< -c $(CFLAGS) -o $@
$(CC) $< -c $(CFLAGS) $(STRICT) -o $@

obj/%.o: $(DEPSDIR)/*/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
$(CC) $< -c $(CFLAGS) $(STRICT) -o $@

$(EXAMPLE_TARGET): $(STATIC_TARGET)
$(CC) $(CFLAGS) $(EXAMPLEDIR)/main.c $< $(LIBS) -o $@
Expand Down
2 changes: 1 addition & 1 deletion t/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "tests.h"

int main(void) {
plan(135);
plan(143);

run_hash_set_tests();
run_hash_table_tests();
Expand Down

0 comments on commit e276ff2

Please sign in to comment.