⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 overview.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>The C Preprocessor</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="The C Preprocessor">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

<!--

Copyright &copy; 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,

1997, 1998, 1999, 2000, 2001, 2002, 2003

Free Software Foundation, Inc.



   <p>Permission is granted to copy, distribute and/or modify this document

under the terms of the GNU Free Documentation License, Version 1.1 or

any later version published by the Free Software Foundation.  A copy of

the license is included in the

section entitled "GNU Free Documentation License".



   <p>This manual contains no Invariant Sections.  The Front-Cover Texts are

(a) (see below), and the Back-Cover Texts are (b) (see below).



   <p>(a) The FSF's Front-Cover Text is:



   <p>A GNU Manual



   <p>(b) The FSF's Back-Cover Text is:



   <p>You have freedom to copy and modify this GNU Manual, like GNU

     software.  Copies published by the Free Software Foundation raise

     funds for GNU development. 

-->

</head>

<body>

<div class="node">

<p>

Node:<a name="Overview">Overview</a>,

Next:<a rel="next" accesskey="n" href="Header-Files.html#Header%20Files">Header Files</a>,

Previous:<a rel="previous" accesskey="p" href="index.html#Top">Top</a>,

Up:<a rel="up" accesskey="u" href="index.html#Top">Top</a>

<hr><br>

</div>



<h2 class="chapter">Overview</h2>



   <p>The C preprocessor, often known as <dfn>cpp</dfn>, is a <dfn>macro processor</dfn>

that is used automatically by the C compiler to transform your program

before compilation.  It is called a macro processor because it allows

you to define <dfn>macros</dfn>, which are brief abbreviations for longer

constructs.



   <p>The C preprocessor is intended to be used only with C, C++, and

Objective-C source code.  In the past, it has been abused as a general

text processor.  It will choke on input which does not obey C's lexical

rules.  For example, apostrophes will be interpreted as the beginning of

character constants, and cause errors.  Also, you cannot rely on it

preserving characteristics of the input which are not significant to

C-family languages.  If a Makefile is preprocessed, all the hard tabs

will be removed, and the Makefile will not work.



   <p>Having said that, you can often get away with using cpp on things which

are not C.  Other Algol-ish programming languages are often safe

(Pascal, Ada, etc.) So is assembly, with caution.  <code>-traditional-cpp</code>

mode preserves more white space, and is otherwise more permissive.  Many

of the problems can be avoided by writing C or C++ style comments

instead of native language comments, and keeping macros simple.



   <p>Wherever possible, you should use a preprocessor geared to the language

you are writing in.  Modern versions of the GNU assembler have macro

facilities.  Most high level programming languages have their own

conditional compilation and inclusion mechanism.  If all else fails,

try a true general text processor, such as GNU M4.



   <p>C preprocessors vary in some details.  This manual discusses the GNU C

preprocessor, which provides a small superset of the features of ISO

Standard C.  In its default mode, the GNU C preprocessor does not do a

few things required by the standard.  These are features which are

rarely, if ever, used, and may cause surprising changes to the meaning

of a program which does not expect them.  To get strict ISO Standard C,

you should use the <code>-std=c89</code> or <code>-std=c99</code> options, depending

on which version of the standard you want.  To get all the mandatory

diagnostics, you must also use <code>-pedantic</code>.  See <a href="Invocation.html#Invocation">Invocation</a>.



   <p>This manual describes the behavior of the ISO preprocessor.  To

minimize gratuitous differences, where the ISO preprocessor's

behavior does not conflict with traditional semantics, the

traditional preprocessor should behave the same way.  The various

differences that do exist are detailed in the section <a href="Traditional-Mode.html#Traditional%20Mode">Traditional Mode</a>.



   <p>For clarity, unless noted otherwise, references to <code>CPP</code> in this

manual refer to GNU CPP.



<ul class="menu">

<li><a accesskey="1" href="Initial-processing.html#Initial%20processing">Initial processing</a>: 

<li><a accesskey="2" href="Tokenization.html#Tokenization">Tokenization</a>: 

<li><a accesskey="3" href="The-preprocessing-language.html#The%20preprocessing%20language">The preprocessing language</a>: 

</ul>



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -