Keil Logo

GENERAL: DIFFERENCES BETWEEN #INCLUDE <FILE> AND "FILE"

Information in this article applies to:

  • C166 Version 4
  • C251 Version 3
  • C51 Version 6 and Higher

SYMPTOMS

If you copy an include file from the \KEIL\Cxx\INC folder to your project folder and attempt to include it using:

#include <filename.h>

the original file from the \INC folder is included instead of the copy.

CAUSE

This is correct behavior. The ANSI standard differentiates between

#include <filename>

and

#include "filename"

The ANSI standard does not specify a search order but recommends that #include <filename> should search implementation-defined locations for header files.

In the Keil C compiler (and most other C compiler implementations) the include file search is implemented as follows:

  • #include <> searches for filename in the directories specified with the INCDIR compiler directive. If this search fails, paths specified by the C51INC, C166INC or C251INC environment variable are used. If this fails the current folder (the folder where the project file is stored) is used. If this fails, the C source file folder is used.
  • #include "filename" searches for filename in the current folder. If this search fails, the C source folder is used. If this fails, the compiler proceeds as if you wrote #include <>.

In the µVision IDE, you may view or change the search path the compiler uses for #include <> statements. From the Project window, click on Project, then Components, Environment, Books to display the Components, Environment, Books dialog. Clicking on the Folders/Extensions tab displays the folders searched by the compiler, assembler and linker. The compiler uses the path name in INC text box for #include <> statements.

RESOLUTION

Use the following preprocessor directive to include your modified header file.

#include "filename.h"

MORE INFORMATION

  • Refer to Environment Settings in the Cx51 User's Guide.
  • Refer to INCDIR in the Cx51 User's Guide.
  • Refer to Environment Settings in the C166 User's Guide.
  • Refer to INCDIR in the C166 User's Guide.
  • Refer to Environment Settings in the C251 User's Guide.
  • Refer to INCDIR in the C251 User's Guide.

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, March 27, 2007


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.