Include Files
Files can be included with the following syntax:
| -include(Filename). |
In Erlang, the convention is that include files have the
extension hrl. The FileName
should contain an
absolute or relative path so that the preprocessor can locate the
appropriate file. Library header files can be included with the following
syntax:
| -include_lib(Name). |
Here’s an example:
| -include_lib("kernel/include/file.hrl"). |
In this case, the Erlang compiler will find the appropriate
include files. (kernel
, in the previous example, refers to the
application that defines this header file.)
Include files usually contain record definitions. If many modules need to share common record definitions, then the common record definitions are put into include ...
Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.