5.3. How the C++ Compiler Searches Include Files. Altium TriCore
Oglas
Oglas
TASKING VX-toolset for TriCore User Guide
5.3. How the C++ Compiler Searches Include Files
When you use include files (with the
#include
statement), you can specify their location in several ways.
The C++ compiler searches the specified locations in the following order:
1. If the
#include
statement contains an absolute pathname, the C++ compiler looks for this file. If no path or a relative path is specified, the C++ compiler looks in the same directory as the source file.
This is only possible for include files that are enclosed in "".
This first step is not done for include files enclosed in <>.
2. When the C++ compiler did not find the include file, it looks in the directories that are specified in the
C/C++ Compiler » Include Paths page in the C/C++ Build » Settings » Tool Settings tab of the
Project Properties dialog (equivalent to the
3. When the C++ compiler did not find the include file (because it is not in the specified include directory or because no directory is specified), it looks in the path(s) specified in the environment variable
CPTCINC
.
4. When the C++ compiler still did not find the include file, it finally tries the default include.cpp
and include
directory relative to the installation directory.
5. If the include file is still not found, the directories specified in the
If the include directory is specified as -, e.g., -I-, the option indicates the point in the list of -I or
options at which the search for file names enclosed in
<...>
should begin. That is, the search for
<...>
names should only consider directories named in -I or
options following the -I-, and the directories of items 3 and 4 above. -I- also removes the directory containing the current input file (item 1 above) from the search path for file names enclosed in
"..."
.
An include directory specified with the
option is considered a "system" include directory.
Warnings are suppressed when processing files found in system include directories.
If the filename has no suffix it will be searched for by appending each of a set of include file suffixes.
When searching in a given directory all of the suffixes are tried in that directory before moving on to the next search directory. The default set of suffixes is, no extension and
.stdh
. The default can be overridden
command line option. A null file suffix cannot be used unless it is present in the suffix list (that is, the C++ compiler will always attempt to add a suffix from the suffix list when the filename has no suffix).
Example
Suppose that the C++ source file test.cc
contains the following lines:
#include <stdio.h>
#include "myinc.h"
You can call the C++ compiler as follows: cptc -Imyinclude test.cc
198
Preuzimanje
Oglas