29.10.2014 Views

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Getting started with <strong>the</strong> <strong>Compiler</strong><br />

3.11 <strong>Compiler</strong> search rules and <strong>the</strong> current place<br />

By default, <strong>the</strong> compiler uses Berkeley UNIX search rules, so source files and #include header<br />

files are searched <strong>for</strong> relative to <strong>the</strong> current place. The current place is <strong>the</strong> directory containing<br />

<strong>the</strong> source or header file currently being processed by <strong>the</strong> compiler.<br />

When a file is found relative to an element of <strong>the</strong> search path, <strong>the</strong> directory containing that file<br />

becomes <strong>the</strong> new current place. When <strong>the</strong> compiler has finished processing that file, it restores<br />

<strong>the</strong> previous current place. At each instant <strong>the</strong>re is a stack of current places corresponding to <strong>the</strong><br />

stack of nested #include directives. For example, if <strong>the</strong> current place is <strong>the</strong> include directory<br />

...\include, and <strong>the</strong> compiler is seeking <strong>the</strong> include file sys\defs.h, it locates<br />

...\include\sys\defs.h if it exists. When <strong>the</strong> compiler begins to process defs.h, <strong>the</strong> current<br />

place becomes ...\include\sys. Any file included by defs.h that is not specified with an<br />

absolute path name, is searched <strong>for</strong> relative to ...\include\sys.<br />

The original current place ...\include is restored only when <strong>the</strong> compiler has finished<br />

processing defs.h.<br />

You can disable <strong>the</strong> stacking of current places by using <strong>the</strong> compiler option --kandr_include.<br />

This option makes <strong>the</strong> compiler use Kernighan and Ritchie search rules whereby each nonrooted<br />

user #include is searched <strong>for</strong> relative to <strong>the</strong> directory containing <strong>the</strong> source file that is being<br />

compiled.<br />

3.11.1 See also<br />

Concepts<br />

• Factors influencing how <strong>the</strong> compiler searches <strong>for</strong> header files on page 3-17.<br />

Reference<br />

• --kandr_include on page 3-55.<br />

O<strong>the</strong>r in<strong>for</strong>mation<br />

• Kernighan, B.W. and Ritchie, D.M., The C Programming Language (2nd edition, 1988).<br />

Prentice-Hall, Englewood Cliffs, NJ, USA. ISBN 0-13-110362-8.<br />

<strong>ARM</strong> DUI 0375C Copyright © 2007-2008, 2011 <strong>ARM</strong>. All rights reserved. 3-19<br />

ID061811<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!