Red Hat ENTERPRISE LINUX 3 - USING CPP Using Instructions page 10

Using cpp, the c preprocessor
Hide thumbs Also See for ENTERPRISE LINUX 3 - USING CPP:
Table of Contents

Advertisement

6
Macro expansion. You can define macros, which are abbreviations for arbitrary fragments of C
code. The preprocessor will replace the macros with their definitions throughout the program. Some
macros are automatically defined for you.
Conditional compilation. You can include or exclude parts of the program according to various
conditions.
Line control. If you use a program to combine or rearrange source files into an intermediate file
which is then compiled, you can use line control to inform the compiler where each source line
originally came from.
Diagnostics. You can detect problems at compile time and issue errors or warnings.
There are a few more, less useful, features.
Except for expansion of predefined macros, all these operations are triggered with preprocessing di-
rectives. Preprocessing directives are lines in your program that start with
before and after the
tion to perform. Directives are commonly referred to as
example,
is the directive that defines a macro.
#define
The
which begins a directive cannot come from a macro expansion. Also, the directive name is not
#
macro expanded. Thus, if
a valid preprocessing directive.
The set of valid directive names is fixed. Programs cannot define new preprocessing directives.
Some directives require arguments; these make up the rest of the directive line and must be separated
from the directive name by whitespace. For example,
and the intended expansion of the macro.
A preprocessing directive cannot cover more than one line. The line may, however, be continued with
backslash-newline, or by a block comment which extends past the end of the line. In either case, when
the directive is processed, the continuations have already been merged with the first line to make one
long line.
. The
is followed by an identifier, the directive name. It specifies the opera-
#
#
is defined as a macro expanding to
foo
where
#
name
name
, that does not make
define
must be followed by a macro name
#define
Chapter 1. Overview
. Whitespace is allowed
#
is the directive name. For
#foo

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents