C and C++ Compilers have flags to toggle on warnings such as -Wall
, -Wextra
, or -Weverything
. It is a good idea to specify as many of them as possible when compiling the code and to fix the warnings where appropriate.
Someone gave me this GCC warnings’ theme:
#!/bin/bash gcc \ -std=c99 \ -ansi \ -pedantic \ -W \ -Wall \ -Wbad-function-cast \ -Wcast-align \ -Wcast-qual \ -Wdeclaration-after-statement \ -Wfloat-equal \ -Wformat-nonliteral \ -Winline \ -Wmissing-declarations \ -Wmissing-prototypes \ -Wnested-externs \ -Wold-style-definition \ -Wpointer-arith \ -Wshadow \ -Wstrict-prototypes \ -Wundef \ -Wunused \ -Wwrite-strings