tags:

views:

206

answers:

1

What is the difference between "include_lib" and "include" ?

E.g.

-include_lib("eunit/include/eunit.hrl")

+6  A: 

The way the documentation describes the difference between include and include_lib is:

include_lib is similar to include, but should not point out an absolute file. Instead, the > first path component (possibly after variable substitution) is assumed to be the name of an > application. Example:

-include_lib("kernel/include/file.hrl").

The code server uses code:lib_dir(kernel) to find the directory of the current (latest) > version of Kernel, and then the subdirectory include is searched for the file file.hrl.

So in your example, you dont need to point out the version of eunit that you include, you are including the latest eunit.hrl of the eunit:s that exists in your library path.

Christian
I believe you can also use include_lib to include files you want from a specific version of an installed application.
Nick Gerakines