/usr/share/doc/gccintro/gccintro/Preprocessing-source-files.html is in gccintro 1.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>An Introduction to GCC: Preprocessing source files</title>
<meta name="description" content="An Introduction to GCC: Preprocessing source files">
<meta name="keywords" content="An Introduction to GCC: Preprocessing source files">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Using-the-preprocessor.html#Using-the-preprocessor" rel="up" title="Using the preprocessor">
<link href="Compiling-for-debugging.html#Compiling-for-debugging" rel="next" title="Compiling for debugging">
<link href="Macros-with-values.html#Macros-with-values" rel="prev" title="Macros with values">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Preprocessing-source-files"></a>
<div class="header">
<p>
Previous: <a href="Macros-with-values.html#Macros-with-values" accesskey="p" rel="prev">Macros with values</a>, Up: <a href="Using-the-preprocessor.html#Using-the-preprocessor" accesskey="u" rel="up">Using the preprocessor</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Preprocessing-source-files-1"></a>
<h3 class="section">4.3 Preprocessing source files</h3>
<a name="index-_002dE-option_002c-preprocess-source-files"></a>
<a name="index-E-option_002c-preprocess-source-files"></a>
<a name="index-preprocessing-source-files_002c-_002dE-option"></a>
<p>It is possible to see the effect of the preprocessor on source files
directly, using the <samp>-E</samp> option of <code>gcc</code>. For example, the
file below defines and uses a macro <code>TEST</code>:
</p>
<div class="example">
<pre class="verbatim">#define TEST "Hello, World!"
const char str[] = TEST;
</pre></div>
<p>If this file is called <samp>test.c</samp> the effect of the preprocessor
can be seen with the following command line:
</p>
<div class="example">
<pre class="example">$ gcc -E test.c
const char str[] = "Hello, World!" ;
</pre></div>
<p>The <samp>-E</samp> option causes <code>gcc</code> to run the preprocessor,
display the expanded output, and then exit without compiling the
resulting source code. The value of the macro <code>TEST</code> is
substituted directly into the output, producing the sequence of
characters <code>const char str[] = "Hello, World!" ;</code>.
</p>
<a name="index-line-numbers_002c-recorded-in-preprocessed-files"></a>
<p>The preprocessor also inserts lines recording the source file and line
numbers in the form <code># <var>line-number</var> "<var>source-file</var>"</code>, to
aid in debugging and allow the compiler to issue error messages
referring to this information. These lines do not affect the program
itself.
</p>
<p>The ability to see the preprocessed source files can be useful
for examining the effect of system header files, and finding declarations
of system functions. The following program includes the header file
<samp>stdio.h</samp> to obtain the declaration of the function <code>printf</code>:
</p>
<div class="example">
<pre class="verbatim">#include <stdio.h>
int
main (void)
{
printf ("Hello, world!\n");
return 0;
}
</pre></div>
<p>It is possible to see the declarations from the included header file by
preprocessing the file with <code>gcc -E</code>:
</p>
<div class="example">
<pre class="example">$ gcc -E hello.c
</pre></div>
<p>On a GNU system, this produces output similar to the following:
</p>
<div class="example">
<pre class="example">
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
extern int fprintf (FILE * __stream,
const char * __format, ...) ;
extern int printf (const char * __format, ...) ;
<span class="roman"><i>[ ... additional declarations ... ]</i></span>
int
main (void)
{
printf ("Hello, world!\n");
return 0;
}
</pre></div>
<p>The preprocessed system header files usually generate a lot of
output. This can be redirected to a file, or saved more conveniently
using the <code>gcc</code> <samp>-save-temps</samp> option:
<a name="index-_002dsave_002dtemps-option_002c-keeps-intermediate-files"></a>
<a name="index-save_002dtemps-option_002c-keeps-intermediate-files"></a>
<a name="index-preprocessed-files_002c-keeping"></a>
<a name="index-intermediate-files_002c-keeping"></a>
<a name="index-temporary-files_002c-keeping"></a>
</p>
<div class="example">
<pre class="example">$ gcc -c -save-temps hello.c
</pre></div>
<p>After running this command, the preprocessed output will be available in
the file <samp>hello.i</samp>. The <samp>-save-temps</samp> option also saves
<samp>.s</samp> assembly files and <samp>.o</samp> object files in addition to
preprocessed <samp>.i</samp> files.
</p>
<hr>
<div class="header">
<p>
Previous: <a href="Macros-with-values.html#Macros-with-values" accesskey="p" rel="prev">Macros with values</a>, Up: <a href="Using-the-preprocessor.html#Using-the-preprocessor" accesskey="u" rel="up">Using the preprocessor</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|