[erlang-questions] -include with define macro

zxq9 zxq9@REDACTED
Mon Sep 21 13:56:16 CEST 2015


On 2015年9月21日 月曜日 14:26:35 Martin Koroudjiev wrote:
> -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'

I think includes run before macros, so your include is trying to include a very odd-looking thing that starts with a question-mark instead of a filename.

Usually things like debug (or other selective behavior definitions) expand to reference a module based on the debug level (or whatever). So ?DEBUG might look like

?DEBUG:report(Foo)

in code and one time expand to: `my_logger:report(Foo)` or `my_full_blown_debugger:reort(Foo)` or `my_do_nothing_module:report(Foo)`. In the last case the function might be optimized out entirely if it really does nothing.

-Craig



More information about the erlang-questions mailing list