C Flags & Options
The C language, its standard library and compilers.All C pages
- gcc -D NAME=value: define a preprocessor macro from the command linegcc -DNAME=value defines a preprocessor macro from the command line: default value 1, string values and quoting, -U to undefine, NDEBUG and feature-test macros.
- gcc -I dir: add a header search path (fix "No such file or directory" for #include)gcc -I dir adds a header search path and fixes file not found errors for #include: search order for quotes and angle brackets, -isystem, pkg-config, pitfalls.
- gcc -O2 vs -O0, -O3, -Os, -Og: C optimization levels explainedgcc -O0, -O1, -O2, -O3, -Os, -Oz, -Og and -Ofast compared: what each level does, the default, predefined macros, and why bugs appear only in optimized builds.
- gcc -Wall -Wextra -Werror: enable compiler warningsgcc -Wall -Wextra enables the warnings that catch most C bugs: unused variables, format mismatches, signed comparisons. -Werror makes warnings fail the build.