1<html lang="en"> 2<head> 3<title>Overview - The C Preprocessor</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="The C Preprocessor"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="prev" href="index.html#Top" title="Top"> 9<link rel="next" href="Header-Files.html#Header-Files" title="Header Files"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 131997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 142008, 2009, 2010, 2011 15Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation. A copy of 20the license is included in the 21section entitled ``GNU Free Documentation License''. 22 23This manual contains no Invariant Sections. The Front-Cover Texts are 24(a) (see below), and the Back-Cover Texts are (b) (see below). 25 26(a) The FSF's Front-Cover Text is: 27 28 A GNU Manual 29 30(b) The FSF's Back-Cover Text is: 31 32 You have freedom to copy and modify this GNU Manual, like GNU 33 software. Copies published by the Free Software Foundation raise 34 funds for GNU development. 35--> 36<meta http-equiv="Content-Style-Type" content="text/css"> 37<style type="text/css"><!-- 38 pre.display { font-family:inherit } 39 pre.format { font-family:inherit } 40 pre.smalldisplay { font-family:inherit; font-size:smaller } 41 pre.smallformat { font-family:inherit; font-size:smaller } 42 pre.smallexample { font-size:smaller } 43 pre.smalllisp { font-size:smaller } 44 span.sc { font-variant:small-caps } 45 span.roman { font-family:serif; font-weight:normal; } 46 span.sansserif { font-family:sans-serif; font-weight:normal; } 47--></style> 48<link rel="stylesheet" type="text/css" href="../cs.css"> 49</head> 50<body> 51<div class="node"> 52<a name="Overview"></a> 53<p> 54Next: <a rel="next" accesskey="n" href="Header-Files.html#Header-Files">Header Files</a>, 55Previous: <a rel="previous" accesskey="p" href="index.html#Top">Top</a>, 56Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> 57<hr> 58</div> 59 60<h2 class="chapter">1 Overview</h2> 61 62<!-- man begin DESCRIPTION --> 63<p>The C preprocessor, often known as <dfn>cpp</dfn>, is a <dfn>macro processor</dfn> 64that is used automatically by the C compiler to transform your program 65before compilation. It is called a macro processor because it allows 66you to define <dfn>macros</dfn>, which are brief abbreviations for longer 67constructs. 68 69 <p>The C preprocessor is intended to be used only with C, C++, and 70Objective-C source code. In the past, it has been abused as a general 71text processor. It will choke on input which does not obey C's lexical 72rules. For example, apostrophes will be interpreted as the beginning of 73character constants, and cause errors. Also, you cannot rely on it 74preserving characteristics of the input which are not significant to 75C-family languages. If a Makefile is preprocessed, all the hard tabs 76will be removed, and the Makefile will not work. 77 78 <p>Having said that, you can often get away with using cpp on things which 79are not C. Other Algol-ish programming languages are often safe 80(Pascal, Ada, etc.) So is assembly, with caution. <samp><span class="option">-traditional-cpp</span></samp> 81mode preserves more white space, and is otherwise more permissive. Many 82of the problems can be avoided by writing C or C++ style comments 83instead of native language comments, and keeping macros simple. 84 85 <p>Wherever possible, you should use a preprocessor geared to the language 86you are writing in. Modern versions of the GNU assembler have macro 87facilities. Most high level programming languages have their own 88conditional compilation and inclusion mechanism. If all else fails, 89try a true general text processor, such as GNU M4. 90 91 <p>C preprocessors vary in some details. This manual discusses the GNU C 92preprocessor, which provides a small superset of the features of ISO 93Standard C. In its default mode, the GNU C preprocessor does not do a 94few things required by the standard. These are features which are 95rarely, if ever, used, and may cause surprising changes to the meaning 96of a program which does not expect them. To get strict ISO Standard C, 97you should use the <samp><span class="option">-std=c90</span></samp>, <samp><span class="option">-std=c99</span></samp> or 98<samp><span class="option">-std=c1x</span></samp> options, depending 99on which version of the standard you want. To get all the mandatory 100diagnostics, you must also use <samp><span class="option">-pedantic</span></samp>. See <a href="Invocation.html#Invocation">Invocation</a>. 101 102 <p>This manual describes the behavior of the ISO preprocessor. To 103minimize gratuitous differences, where the ISO preprocessor's 104behavior does not conflict with traditional semantics, the 105traditional preprocessor should behave the same way. The various 106differences that do exist are detailed in the section <a href="Traditional-Mode.html#Traditional-Mode">Traditional Mode</a>. 107 108 <p>For clarity, unless noted otherwise, references to ‘<samp><span class="samp">CPP</span></samp>’ in this 109manual refer to GNU CPP. 110<!-- man end --> 111 112<ul class="menu"> 113<li><a accesskey="1" href="Character-sets.html#Character-sets">Character sets</a> 114<li><a accesskey="2" href="Initial-processing.html#Initial-processing">Initial processing</a> 115<li><a accesskey="3" href="Tokenization.html#Tokenization">Tokenization</a> 116<li><a accesskey="4" href="The-preprocessing-language.html#The-preprocessing-language">The preprocessing language</a> 117</ul> 118 119 </body></html> 120 121