Namespaces
Variants
Views
Actions

Source file inclusion

From cppreference.com
< c‎ | preprocessor
Revision as of 16:39, 5 June 2013 by P12 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Includes other source file into current source file at the line immediately after the directive .

[edit] Syntax

#include <filename> (1)
#include "filename" (2)

[edit] Explanation

Includes source file, identified by filename into the current source file at the line immediately after the directive.

The first version of the directive searches only standard include directories. The standard C++ library, as well as standard C library, is implicitly included in standard include directories. The standard include directories can be controlled by the user through compiler options.

The second version firstly searches the directory where the current file resides and, only if the file is not found, searches the standard include directories.

In the case the file is not found, program is ill-formed.