Skip to content

Instantly share code, notes, and snippets.

@ggorlen
Created July 30, 2021 02:03
Show Gist options
  • Select an option

  • Save ggorlen/5642fc52bbbde5edc960142682af2b80 to your computer and use it in GitHub Desktop.

Select an option

Save ggorlen/5642fc52bbbde5edc960142682af2b80 to your computer and use it in GitHub Desktop.
Compile C script
#!/usr/bin/env bash
if [ "$#" -ne 2 ]; then
echo "Usage: ./compile_c.sh in.c out.out"
exit 1
elif [ $1 -eq $2 ]; then
echo "error: overwriting source file '$1'"
exit 1
fi
gcc -std=c99 -pedantic -Wall \
-Wno-missing-braces -Wextra -Wno-missing-field-initializers -Wformat=2 \
-Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith \
-Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline \
-Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code \
-Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 -Wredundant-decls \
-Wold-style-definition -Werror \
-ggdb3 \
-O0 \
-fno-omit-frame-pointer -ffloat-store -fno-common -fstrict-aliasing \
-lm \
-o $2 \
$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment