Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Itanium-based Systems: HP aC++/HP C Programmer's Guide > Chapter 2 Command-Line Options

Header File Options

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Following are the command-line options you can use for header files:

-H

cc -H file

The -H option causes HP aC++/HP C to print the order and hierarchy of included files. The -H option dumps the include heirarcy to stderr so that the preprocessed compiler output indicates the include file nesting.

+hdr_create

aCC progname -c +hdr_create headername

This option extracts the header from a program file and saves it as a precompiled header file.

Example: aCC ApplicTemplate.C -c +hdr_create ApplicHeader

+hdr_use

aCC progname +hdr_use headerfile -c

This option adds a precompiled header file to a program when the program is compiled.

Example: aCC Applic.C +hdr_use ApplicHeader -c

-I directory

-I directory

directory is the HP-UX directory where the compiler looks for header files.

During the compile phase, this option adds directory to the directories to be searched for #include files during preprocessing. During the link phase, this option adds directory to the directories to be searched for #include files by the link-time template processor.

For #include files that are enclosed in double quotes (" ") within a source file and do not begin with a /, the preprocessor searches in the following order:

  1. The directory of the source file containing the #include.

  2. The directory named in the -I option.

  3. The standard include directories /opt/aCC/include and /usr/include.

For #include files that are enclosed in angle brackets (< >), the preprocessor searches in the following order:

  1. The directory named in the -I option.

  2. The standard include directories /opt/aCC/include and /usr/include.

NOTE: The current directory is not searched when angle brackets (< >) are used with #include.

Example:

The following example directs the compiler to search in the directory include for #include files.

aCC -I include file.C

-I-

[-Idirs] -I- [-Idirs]

[-Idirs] indicates an optional list of -Idirectory specifications in which a directory name cannot begin with a hyphen (-) character.

The -I- option allows you to override the default -Idirectory search-path. This feature is called view-pathing. Specifying -I- serves two purposes:

  1. It changes the compiler’s search-path for quote enclosed (" ") file names in a #include directive to the following order:

    1. The directory named in the -I option.

    2. The standard include directories /opt/aCC/include* and /usr/include.

      The preprocessor does not search the directory of the including file.

  2. It separates the search-path list for quoted and angle-bracketed include files.

    Angle-bracket enclosed file names in a #include directive are searched for only in the -I directories specified after -I- on the command-line. Quoted include files are searched for in the directories that both precede and follow the -I- option.

The standard aCC include directories (/usr/include and /opt/aCC/include*) are always searched last for both types of include files.

Usage:

View-pathing can be particularly valuable for medium to large sized projects. For example, imagine that a project comprises two sets of directories. One set contains development versions of some of the headers that the programmer currently modifies. A mirror set contains the official sources.

Without view-pathing, there is no way to completely replace the default -Idirectory search-path with one customized specifically for project development.

With view-pathing, you can designate and separate official directories from development directories and enforce an unconventional search-path order. For quote enclosed headers, the preprocessor can include any header files located in development directories and, in the absence of these, include headers located in the official directories.

If -I- is not specified, view-pathing is turned off. This is the default.

Examples:

With view-pathing off, the following example obtains all the quoted include files from dir1 only if they are not found in the directory of a.C and from dir2 only if they are not found in dir1. Finally, if necessary, the standard include directories are searched. Angle-bracketed include files are searched for in dir1, then dir2, followed by the standard include directories.

aCC -Idir1 -Idir2 -c a.C

With view-pathing on, the following example searches for quoted include files in dir1 first and dir2 next, followed by the standard include directories, ignoring the directory of a.C. Angle-bracketed includes are searched for in dir2 first, followed by the standard include directories.

aCC -Idir1 -I- -Idir2 -c a.C

NOTE: Some of the compiler’s header files are included using double quotes. Since the -I- option redefines the search order of such includes, if any standard headers are used, it is your responsibility to supply the standard include directories (/opt/aCC/include* and /usr/include) in the correct order in your -I- command line.

For example, when using -I- on the aCC command line, any specified -I directory containing a quoted include file having the same name as an HP-UX system header file, may cause the following possible conflict.

In general, if your application includes no header having the same name as an HP-UX system header, there is no chance of a conflict.

Suppose you are compiling program a.C with view-pathing on. a.C includes the file a.out.h which is a system header in /usr/include:

aCC -IDevelopmentDir -I- -IOfficialDir a.C

If a.C contains:

// This is the file a.C
#include <a.out.h>
// ...

When a.out.h is preprocessed from the /usr/include directory, it includes other files that are quote included (like #include "filehdr.h").

Since with view-pathing, quote enclosed headers are not searched for in the including file’s directory, filehdr.h which is included by a.out.h will not be searched for in a.out.h’s directory (/usr/include).

Instead, for the above command line, the system header is first searched for in DevelopmentDir, then in OfficialDir and if it is found in neither, it is finally searched for in the standard include directories, /opt/aCC/include* and /usr/include, in the latter of which it will be found.

However, if you have a file named filehdr.h in DevelopmentDir or OfficialDir, that file (the wrong file) will be found.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.