It costs nothing that jsonerl.hrl does not contain any functions. It contains macros. As far as I know, macros are only time compilation in Erlang.
The easiest way to make them available is to create an .erl file that will actually declare functions implemented in macro terms. Maybe something like this:
-module(jsonerl_helpers). -include("jsonerl.hrl"). record_to_struct_f(RecordName, Record) -> ?record_to_struct(RecordName, Record).
... which, after compilation, you can call as:
jsonerl_helpers:record_to_struct_f(RecordName, Record)
I do not know why the author decided to implement them as macros; it seems strange, but I'm sure he had reasons.
Daniel Yankowsky
source share