[erlang-questions] -include with define macro

Martin Koroudjiev mrtndimitrov@REDACTED
Mon Sep 21 13:26:35 CEST 2015


Hello,

I am working on an app that will often be included into bigger
applications. In an .hrl file, my app defines some debug macros. But I
would like to allow the enclosing app to provide a better, more specific
to its needs, implementation of these macros. So in the .hrl file I do:

-ifndef(DEBUG).
-define(DEBUG(Format, Args),
    io:format("DEBUG: ~p ~p: "++Format, [?MODULE, ?LINE | Args])).
-endif.

In all my source files, I include the .hrl file. But how should I
include the enclosing app .hrl file where the DEBUG macro is defined? I
tried this:

-ifdef(CONTAINING_APP_INCLUDE).
-include(?CONTAINING_APP_INCLUDE).
-endif.

and to compile the source files as:

erlc -Werror -Wall -DCONTAINING_APP_INCLUDE="\"<path>/<file>.hrl\""
<module>.erl

but I get the following error:

badly formed 'include'

Thanks in advance for taking the time to look at this.

Regards,
Martin



More information about the erlang-questions mailing list