Bugfix/code clean using gcc warnings (#371)

* Enable extra GCC warnings to discover subtle bugs

* convert c++ comments to c comments

* cleanup pedantic compiler warnings

* Compile apps with GNU89 GNU99 GNU11 and GNU17

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-12-25 21:43:51 -06:00
committed by GitHub
parent 0728bc4390
commit b91735af13
66 changed files with 990 additions and 847 deletions
+20 -5
View File
@@ -94,16 +94,31 @@ BACNET_PORT_DIR = $(realpath ../ports/$(BACNET_PORT))
BACNET_SRC_DIR = $(realpath ../src)
# Compiler flag to set the C Standard level.
# c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c89 - "ANSI" C - ISO C90
# gnu89 - c89 plus GNU extensions
# c90 - "ANSI" C - ISO C90
# gnu90 - C90 with GNU extensions
# c99 - ISO C99 standard
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu89
# gnu99 - C99 plus GNU extensions
# c11 - C11
# gnu11 - C11 plus GNU extensions
# c17 - C11 with corrections
# note: default is compiled as ANSI C for widest compiler compatibilty
# note: code that requires newer language features must use __STDC_VERSION__
CSTANDARD ?= -std=gnu89
#build for release (default) or debug
OPTIMIZATION ?= -Os
DEBUGGING ?=
WARNINGS ?= -Wall -Wmissing-prototypes -Wno-missing-braces
WARNING_ALL := -Wall -Wextra -Wall -Wfloat-equal -Wconversion -Wparentheses
WARNING_ALL += -pedantic -Wunused-parameter -Wunused-variable -Wreturn-type
WARNING_ALL += -Wunused-function -Wreturn-type -Wunused-value
WARNING_ALL += -Wswitch-default -Wuninitialized -Winit-self
WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
WARNING_ALL += -Wno-long-long
#WARNING_ALL += -Wredundant-decls
#WARNING_ALL += -Werror
WARNINGS ?= $(WARNING_ALL)
# dead code removal
ifeq (${BUILD},debug)
OPTIMIZATION = -O0