HP C/iX Reference Manual (31506-90011)

Chapter 7 97
Preprocessing Directives
Source File Inclusion
Source File Inclusion
You can include the contents of other files within the source file using the #include
directive.
Syntax
include-directive
:=
#include <
filename
>
#include "
filename
"
#include
identifier
Description
The #include preprocessor directive enables you to insert the contents of the specified
external file into the source file prior to compilation. The file name in the #include
directive may be enclosed in angle brackets (< >) or double quotation marks . File names
enclosed in angle brackets are assumed to be standard include files that are provided with
the HP C/iX compiler. All standard include files reside in the H group of the SYS account.
The arguments to the #include directive are subject to macro replacement before the
directive processes them. In the third form above,
identifier
must be in the form of one
of the first two choices after macro replacement by the preprocessor.
For example:
#define varname "my_file"
#include varname
Error messages produced by the compiler usually supply the file name where the error
occurred as well as the file relative line number of the error.
The HP C/iX preprocessing phase allows for the use of non-standard (UNIX
1
-like root
names) file names in certain #include directives. This minimizes the required source code
changes when transporting code between different systems.
The preprocessor strips include file names enclosed in angle brackets of all prefixes and
suffixes. The preprocessor then searches for a file with the resulting name in the H group of
the SYS account. If the file is not found, an error is issued.
For example, if you specify the following directive:
#include <stdio.h>
the preprocessor searches for STDIO.H.SYS. If you specify:
#include <sys/errno.h>
the preprocessor strips the sys/ prefix and searches for ERRNO.H.SYS.
1. UNIX is a trademark of AT&T in the U.S. and other countries.