[Erlang Systems]

5 Includes

There are two directives which can be used in an Erlang source file to cause the compiler to temporarily read input from another source. They are typically used to provide macro definitions and record definitions from header files. It is recommended to use the file name extension ".hrl" for files which are meant to be included (the 'h' can be read as "header").

5.1 The -include directive

The compiler searches for the specified header file in each directory in the compiler's include path. The first file found is included. Example:

        -include("my_records.hrl").

The current directory is implicitly a member of the compiler's include path.

5.2 The -include_lib directive

The -include_lib directive instructs the compiler/preprocessor to look for a header file in an application directory. The first part of the specified pathname) is taken as the name of an application, and the current version of that application will be used. Example:

        -include_lib("mnesia/include/mnemosyne.hrl").

This instructs the compiler/preprocessor to look for the directory where the application called mnesia is installed and then looks in the subdirectory include for the file mnemosyne.hrl.

The preprocessor first looks in the ordinary preprocessor search path to allow explicit overloading of the header files.


Copyright © 1991-2001 Ericsson Utvecklings AB