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