Tokenization - Red Hat ENTERPRISE LINUX 3 - USING CPP Using Instructions

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

Advertisement

Chapter 1. Overview
But beware of commenting out one end of a block comment with a line comment.
// l.c.
/* block comment begins
oops! this isn't a comment anymore */
Comments are not recognized within string literals. "/* blah */" is the string constant
not an empty string.
Line comments are not in the 1989 edition of the C standard, but they are recognized by GCC as an
extension. In C++ and in the 1999 edition of the C standard, they are an official part of the language.
Since these transformations happen before all other processing, you can split a line mechanically
with backslash-newline anywhere. You can comment out the end of a line. You can continue a line
comment onto the next line with backslash-newline. You can even split
lines with backslash-newline. For example:
/\
*
*/ # /*
*/ defi\
ne FO\
O 10\
20
is equivalent to
#define FOO 1020
in code intended to be readable.
There is no way to prevent a backslash at the end of a line from being interpreted as a backslash-
newline.
"foo\\
bar"
is equivalent to
"foo\bar"
deprecated GNU extension that permits multi-line strings. Instead, use string literal concatenation:
"foo\\"
"bar"
Your program will be more portable this way, too.

1.2. Tokenization

After the textual transformations are finished, the input file is converted into a sequence of prepro-
cessing tokens. These mostly correspond to the syntactic tokens used by the C compiler, but there are
a few differences. White space separates tokens; it is not itself a token of any kind. Tokens do not have
to be separated by white space, but it is often necessary to avoid ambiguities.
. All these tricks are extremely confusing and should not be used
, not to
"foo\\bar"
. To avoid having to worry about this, do not use the
/* blah */
,
, and
onto multiple
/*
*/
//
3
,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents