-qinclude

Category

Input control

Pragma equivalent

None.

Purpose

Specifies additional header files to be included in a compilation unit, as though the files were named in an #include statement in the source file.

The headers are inserted before all code statements and any headers specified by an #include preprocessor directive in the source file. This option is provided for portability among supported platforms.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-noinclude--------------.   
>>- -q--+- include--=--file_path-+-----------------------------><

Defaults

-qnoinclude

Parameters

file_path
The absolute or relative path and name of the header file to be included in the compilation units being compiled. If file_path is specified with a relative path, the search for it follows the sequence described in Directory search sequence for include files.

Usage

The usage of the -qinclude option is similar to that of the #include directive. This section describes the differences between using -qinclude and #include.

The -qinclude option applies only to the files specified in the same compilation in which the option is specified. It is not passed to any compilations that occur during the link step, nor to any implicit compilations.

When the option is specified multiple times in an invocation, the header files are included in order of appearance on the command line. If the same header file is specified multiple times with this option, the header is treated as if included multiple times by #include directives in the source file, in order of appearance on the command line.

Specifying -qnoinclude ignores any previous specification of -qinclude. Only the specifications of -qinclude after-qnoinclude are effective.

Any pragma directives that must appear before noncommentary statements in a source file will be affected; you cannot use -qinclude to include files if you need to preserve the placement of these pragmas.

The following rules apply when you use -qinclude with other options:
  • If you generate a listing file with -qsource, the header files included by -qinclude do not appear in the source section of the listing. Use -qshowinc=usr or -qshowinc=all in conjunction with -qsource if you want these header files to appear in the listing.
  • After searching the directory from which the compiler was invoked, -qinclude searches additional search paths added to the search chain by the -I option. You can specify the -I option before or after the -qinclude option.
  • Files specified with -qinclude are included as dependencies in the -M output. However, the paths are different in the dependency file for the -qinclude option and the #include directive, because the files specified with the -qinclude option are searched in the invocation path first, whereas files included by the #include directive are not.

    When a dependency file is created as a result of a first build with the -qinclude option, a subsequent build without the -qinclude option will trigger recompile if the header file on the -qinclude option was touched between the two builds.

  • In the compiler listing file generated by the -qlistopt option, each use of the -qinclude option has a separate entry in the OPTION SECTION.
  • If both the -qsource option and the -qinclude option are used, header files specified with -qinclude are not included in the program source listing as #include directives. However, the files specified on #include directives in source programs are included.

Predefined macros

None.

Examples

To include the files test1.h and test2.h in the source file test.c, enter the following command:
xlc -qinclude=test1.h test.c  -qinclude=test2.h

Related information