From 03fcfd1ba1627f5af84a84a8e0876d19ed88eefa Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 24 Apr 2014 08:59:48 +0200 Subject: m + enable more warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- .gitignore | 10 ++++++++-- Makefile | 25 +++++++++++++++++++------ hungarian.c | 6 +++--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 45282db..78116e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ /hungarian - *~ \#*\# -.\#* +.* +!.git* *.bak *.swp +*.swo +*.su +*.o +*.out +*.gch + diff --git a/Makefile b/Makefile index 75eade0..514127a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,21 @@ -all: - gcc -g -o "hungarian"{,.c} +OPTIMISE = -Og -g +WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs \ + -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations \ + -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wsync-nand \ + -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow \ + -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance \ + -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn \ + -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -Wconversion \ + -fstrict-aliasing -fstrict-overflow -fipa-pure-const -ftree-vrp -fstack-usage \ + -funsafe-loop-optimizations +# excluded: -Wdeclaration-after-statement -nodebug: - gcc -o "hungarian"{,.c} + +all: hungarian + +hungarian: hungarian.c + gcc -std=c99 $(OPTIMISE) $(WARN) -o $@ $< test: ./"hungarian" @@ -11,8 +24,8 @@ valgrind: valgrind --tool=memcheck --leak-check=full ./"hungarian" clean: - if [ -f "hungarian" ]; then unlink "hungarian"; fi + -rm - hungarian -.PHONY: test valgrind clean +.PHONY: all test valgrind clean diff --git a/hungarian.c b/hungarian.c index 5c82db3..cac5211 100644 --- a/hungarian.c +++ b/hungarian.c @@ -127,7 +127,7 @@ void BitSet_set(BitSet this, long i); void BitSet_unset(BitSet this, long i); long BitSet_any(BitSet this); -long lb(llong x); +long lb(llong x) __attribute__((const)); @@ -136,8 +136,8 @@ void print(cell** t, long n, long m, long** assignment); int main(int argc, char** argv) { unsigned a, d; - asm("cpuid"); - asm volatile("rdtsc" : "=a" (a), "=d" (d)); + __asm__("cpuid"); + __asm__ __volatile__("rdtsc" : "=a" (a), "=d" (d)); srand(((llong)a) | (((llong)d) << 32LL)); -- cgit v1.2.3-70-g09d2