Wrapper Headers - 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 2. Header Files
#include HEADER
looks for a file named
cludes.
If the line expands to a token stream beginning with a

between the
and the first
between tokens is reduced to a single space; then any space after the initial
space before the closing
includes.
In either case, if there are any tokens on the line after the file name, an error occurs and the directive
is not processed. It is also an error if the result of expansion does not match either of the two expected
forms.
These rules are implementation-defined behavior according to the C standard. To minimize the risk
of different compilers interpreting your computed includes differently, we recommend you use only
a single object-like macro which expands to a string constant. This will also minimize confusion for
people reading your program.

2.6. Wrapper Headers

Sometimes it is necessary to adjust the contents of a system-provided header file without editing it
directly. GCC's
fixincludes
a new header file with the same name and insert it in the search path before the original header. That
works fine as long as you're willing to replace the old header entirely. But what if you want to refer to
the old header from the new one?
You cannot simply include the old header with
find your new header again. If your header is not protected from multiple inclusion (Refer to Section
2.4 Once-Only Headers), it will recurse infinitely and cause a fatal error.
You could include the old header with an absolute pathname:
#include "/usr/include/old-header.h"
This works, but is not clean; should the system headers ever move, you would have to edit the new
headers to match.
There is no way to solve this problem within the C standard, but you can use the GNU exten-
sion
#include_next
except in searching for the specified file: it starts searching the list of header file directo-
#include
ries after the directory in which the current file was found.
Suppose you specify
includes
/usr/include


finds the file under
signal.h


, it starts searching after that directory, and finds the file in
signal.h
does not distinguish between
#include_next
the file you specify has the same name as the current file. It simply looks for the file named, starting
with the directory in the search path after the one where the current file was found.
The use of
#include_next
no other alternative. In particular, it should not be used in the headers belonging to a specific program;
it should be used only to make global corrections along the lines of
. CPP searches for the file according to the rules for double-quoted in-
a\"b

are combined to form the filename to be included. Any whitespace

is ignored. CPP searches for the file according to the rules for angle-bracket
operation does this, for example. One way to do that would be to create
. It means, "Include the next file with this name." This directive works like
-I /usr/local/include
; and suppose both directories contain
/usr/local/include
can lead to great confusion. We recommend it be used only when there is

token and including a
. That will start from the beginning, and
#include
, and the list of directories to search also
signal.h
. If that file contains


and
"
"
file
file
fixincludes

token, then the tokens

is retained, but a trailing
. Ordinary
#include_next
.
/usr/include
inclusion, nor does it check that
.
11
#include

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents