File inclusion, Mikroc – ABL electronic PIC Microcontrollers PIC16 User Manual

Page 138

Advertising
background image

File Inclusion

The preprocessor directive

#include

pulls in header files (extension

.h

) into the

source code. Do not rely on preprocessor to include source files (extension

.c

) —

see Projects for more information.

The syntax of

#include

directive has two formats:

#include <

header_name

>

#include "

header_name

"

The preprocessor removes the

#include

line and replaces it with the entire text

of the header file at that point in the source code. The placement of the

#include

can therefore influence the scope and duration of any identifiers in the included
file.

The difference between the two formats lies in the searching algorithm employed
in trying to locate the include file.

If

#include

directive was used with the

<

header_name

>

version, the search is

made successively in each of the following locations, in this particular order:

1. mikroC installation folder > “include” folder,
2. your custom search paths.

The

"

header_name

"

version specifies a user-supplied include file; mikroC will

look for the header file in following locations, in this particular order:

1. the project folder (folder which contains the project file

.ppc

),

2. mikroC installation folder > “include” folder,
3. your custom search paths.

Explicit Path

If you place an explicit path in the

header_name

, only that directory will be

searched. For example:

#include "C:\my_files\test.h"

mikroC - C Compiler for Microchip PIC microcontrollers

mikroC

making it simple...

130

MikroElektronika: Development tools - Books - Compilers

page

Advertising
This manual is related to the following products: