# CFLAGS

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/CFLAGS
> Markdown URL: https://mediated.wiki/source/CFLAGS.md
> Source: https://en.wikipedia.org/wiki/CFLAGS
> Source revision: 1284469999
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Compiler option for C and C++ software development

**CFLAGS** and **CXXFLAGS** are either the name of [environment variables](/source/Environment_variable) or of [Makefile](/source/Makefile) variables that can be set to specify additional [switches](/source/Switch_(command_line)) to be passed to a [compiler](/source/Compiler) in the process of building [computer software](/source/Computer_software). **FFLAGS** fulfills a similar role.[1]

These variables are usually set inside a Makefile and are then appended to the command line when the compiler is invoked. If they are not specified in the Makefile, then they will be read from the environment, if present. Tools like [autoconf](/source/Autoconf)'s ./configure script will usually pick them up from the environment and write them into the generated Makefiles. Some package install scripts, like SDL, allow CFLAGS settings to override their normal settings (instead of append to them), so setting CFLAGS can cause harm in this case.

**CFLAGS** enables the addition of switches for the [C](/source/C_(programming_language)) compiler, while **CXXFLAGS** is meant to be used when invoking a [C++](/source/C%2B%2B) compiler. Similarly, a variable **CPPFLAGS** exists with switches to be passed to the [C or C++ preprocessor](/source/C_preprocessor). Similarly, **FFLAGS** enables the addition of switches for a [Fortran](/source/Fortran) compiler.

These variables are most commonly used to specify [optimization](/source/Optimization_(computer_science)) or [debugging](/source/Debugging) switches to a compiler, as for example -g, -O2 or ([GCC](/source/GNU_Compiler_Collection)-specific) -march=athlon.

## See also

- [Compiler optimization](/source/Compiler_optimization)

## References

1. **[^](#cite_ref-FOOTNOTEStallmanMcGrathSmith2020sec.10.3_1-0)** [Stallman, McGrath & Smith 2020](#CITEREFStallmanMcGrathSmith2020), sec.10.3.

Stallman, Richard M.; McGrath, Roland; Smith, Paul D. (2020) [1st pub. 1988]. [*GNU Make. A Program for Directing Recompilation*](https://www.gnu.org/software/make/manual/make.pdf) (PDF). Free Software Foundation.

## External links

- [GNU optimization page](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html)

- [Gentoo Wiki CFLAG guide](http://wiki.gentoo.org/wiki/CFLAGS)

- [Gentoo Wiki guide to safe CFLAGS](http://wiki.gentoo.org/wiki/Safe_CFLAGS)

- [Linux Review page on optimized gcc compiling](http://linuxreviews.org/howtos/compiling/)

This computing article is a stub. You can help Wikipedia by adding missing information.

- [v](https://en.wikipedia.org/wiki/Template:Compu-stub)
- [t](/source/Template_talk%3ACompu-stub)
- [e](https://en.wikipedia.org/wiki/Special:EditPage/Template:Compu-stub)

---
Adapted from the Wikipedia article [CFLAGS](https://en.wikipedia.org/wiki/CFLAGS) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/CFLAGS?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
