Skip to content

Instantly share code, notes, and snippets.

@joekir
Last active December 9, 2017 20:18
Show Gist options
  • Save joekir/25bd2c4e67aeb4836107575133c5cfc1 to your computer and use it in GitHub Desktop.
Save joekir/25bd2c4e67aeb4836107575133c5cfc1 to your computer and use it in GitHub Desktop.
A script that uses all available gcc flags to catch security issues when compiling c
.SILENT:
FILES = main.c
OUT_BIN = out
build: $(FILES)
# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
gcc -Werror=all -Werror=conversion -Werror=stack-protector \
-Werror=pointer-sign -Werror=cast-align -Werror=cast-qual \
-Wextra -Werror=format-security -Wfatal-errors -o $(OUT_BIN) $(FILES)
clean:
rm $(OUT_BIN)
rebuild: clean build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment