ARM Technical Support Knowledge Articles

Header file searching with -I and -J

Applies to: ARM Developer Suite (ADS), DS-5, RealView Developer Kit (RVDK) for OKI, RealView Development Suite (RVDS)

Answer

The compiler switches -I and -J control the searching order for header files.

In ADS, "-I- and "-J-" were used to force the searching of the "in-memory file system" (where the ARM-supplied standard C include header files were built-into the compiler). These allowed you to specify e.g. "armcc -J special_dir -J-", to force the compiler to search "special_dir" before the "in-memory file system".

The "in-memory file system" was a part of the old ADS compiler front-end, but is no longer present in the new RVCT 2.0/2.1 front-end.
In RVCT 2.0/2.1, use of "-I-" or "-J-" now results in the compiler reporting:

"Fatal error: C3465E: The in-memory file system is obsolete, use the normal include mechanisms".

To convert your ADS makefiles or build scripts to work with RVCT and later you will need to remove any occurences of "-I- or "-J-" and replace them with "-Idir" or "-Jdir" as described in section 3.9 - Factors influencing how the compiler searches for header files from the ARM Compiler toolchain documentation.

For application header files (#include "file.h"), the "-Idir" are searched first then "-Jdir" (and then RVCTxxINC or ARMxxINC if set).

For system header files (#include <file.h>), the "-Jdir" are searched first (then RVCTxxINC or ARMxxINC if set) then "-Idir".

If you need to replace the ARM-supplied system header files (for example, <stdio.h>) with your own, and force the compiler to search your own include directories before the ARM-supplied include directories, then compile using -I and -J on the command-line like this (for Windows):

-I"path to your application (double quote) headers" -J"path to your system (angle bracket) headers,%RVCTxxINC%"

For Unix, replace %RVCTxxINC% with $RVCTxxINC or $ARMxxINC .

If your application headers and system headers are in the same directory, then you can use just -J on its own like:

-J"c:\myinclude,%RVCTxxINC%"

Note that the environment variable RVCTxxINC (ARMxxINC in ARM Compiler toolchain 4.1 and later) is, by default, a path containing spaces (for example, C:\Program Files\ARM\RVCT\Data\...), so needs to be enclosed within double quotes. "xx" can be one of 20, 21, 22, 30, 31, 40, 41, or 50, which stands for the RVCT/ARM Compiler toolchain version.

RVCT 2.0 and later provide a new feature - PreCompiled Header (PCH) files, which offers similar speed benefits to the old "in-memory file system". When compiling single source files with the --pch option, header files are only compiled once. Subsequent compilations are then performed faster by using the precompiled files.

Article last edited on: 2011-08-25 17:01:20

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential