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

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

Advertisement

4
When faced with a sequence of characters that has more than one possible tokenization, the prepro-
cessor is greedy. It always makes each token, starting from the left, as big as possible before moving
on to the next token. For instance,
even though the latter tokenization could be part of a valid C program and the former could not.
Once the input file is broken into tokens, the token boundaries never change, except when the
preprocessing operator is used to paste tokens together. (Refer to Section 3.5 Concatenation.) For
example,
#define foo() bar
foo()baz
==> bar baz
not
==> barbaz
The compiler does not re-tokenize the preprocessor's output. Each preprocessing token becomes one
compiler token.
Preprocessing tokens fall into five broad classes: identifiers, preprocessing numbers, string literals,
punctuators, and other. An identifier is the same as an identifier in C: any sequence of letters, digits,
or underscores, which begins with a letter or underscore. Keywords of C have no significance to the
preprocessor; they are ordinary identifiers. You can define a macro whose name is a keyword, for
instance. The only identifier that can be considered a preprocessing keyword is
Section 4.2.3 Defined.
This is mostly true of other languages that use the C preprocessor. However, a few of the keywords of
C++ are significant even in the preprocessor. Refer to Section 3.7.4 C++ Named Operators.
In the 1999 C standard, identifiers may contain letters that are not part of the "basic source charac-
ter set," at the implementation's discretion (such as accented Latin letters, Greek letters, or Chinese
ideograms). This may be done with an extended character set, or the
GCC does not presently implement either feature in the preprocessor or the compiler.
As an extension, GCC treats
where
is commonly used in system-defined function and object names.
$
conforming mode, or if you specify the
A preprocessing number has a rather bizarre definition. The category includes all the normal integer
and floating point constants one expects of C, but also a number of other things one might not initially
recognize as a number. Formally, preprocessing numbers begin with an optional period, a required
decimal digit, and then continue with any sequence of letters, digits, underscores, periods, and expo-
nents. Exponents are the two-character sequences
that begin with
or
p
P
The purpose of this unusual definition is to isolate the preprocessor from the full complexity of nu-
meric constants. It does not have to distinguish between lexically valid and invalid floating-point
numbers, which is complicated. The definition also permits you to split an identifier at any position
and get exactly two tokens, which can then be pasted back together with the
It's possible for preprocessing numbers to cause programs to be misinterpreted. For example,
is a preprocessing number which does not translate to any valid numeric constant, therefore a syntax
error. It does not mean
String literals are string constants, character constants, and header file names (the argument of
1
).
String constants and character constants are straightforward: ". . . " or '. . . '. In either
#include
case embedded quotes should be escaped with a backslash: '\" is the character constant for
1. The C standard uses the term string literal to refer only to what we are calling string constants.
a+++++b
as a letter. This is for compatibility with some systems, such as VMS,
$
-$
are new to C99. They are used for hexadecimal floating-point constants.)
, which is what you might have intended.
0xE + 12
is interpreted as
a ++ ++ + b
option. Refer to Chapter 12 Invocation.
,
,
,
e+
e-
E+
E-
Chapter 1. Overview
, not as
defined
and
escape sequences.
\u
\U
is not a letter in strictly
$
,
,
,
, and
. (The exponents
p+
p-
P+
P-
operator.
##
,
a ++ + ++ b
##
. Refer to
0xE+12
. There
'

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents