Next: , Previous: Using pragma foreign_export for Erlang, Up: Interfacing with Erlang   [Contents] Using pragma foreign_decl for Erlang

pragma foreign_decl’ declarations for Erlang can be used to provide any top-level Erlang declarations (e.g. ‘-define’ macro declarations) which are needed by Erlang code.

pragma foreign_decl’ blocks which do not have the ‘local’ attribute will be copied into the ‘.hrl’ header file for that module, and automatically included by other modules that import the module. Therefore ‘-export’ directives and Erlang module attributes should only appear in ‘local’ blocks.

For example:

:- pragma foreign_decl("Erlang", "
    -define(FOO, 42).
:- pred hello(io.state::di, io.state::uo) is det.
:- pragma foreign_proc("Erlang",
    hello(_IO0::di, _IO::uo),
    [will_not_call_mercury, promise_pure],
    io:format(""FOO = ~w~n"", [?FOO])