is the ifdef macro supposed to work in the middle of a function?

Raimo Niskanen <>
Fri Jul 12 13:47:18 CEST 2002


Perhaps more feature than bug, rather more "defined behaviour". The
preprocessor parses "complete forms", and the "a(1) -> ok;" is not a
complete form since it does not end with a full stop (i.e "."). So the
'-ifdef' stuff can only be used to encapsulate a complete function
definition. Not at all as flexible as the 'C' preprocessor, alas.

/ Raimo Niskanen, Erlang/OTP, Ericsson AB.




Matthias Lang wrote:
> 
> Hi,
> 
> Feature or bug?
> 
> ----------------------------------------------------------------------
> -module(macro).
> 
> %% The following works
> -ifdef(BLO).
> b(1) -> ok.
> -endif.
> 
> %% But this does not work: macro.erl:14: unterminated '-ifdef'
> -ifdef(BLA).
> a(1) -> ok;
> -endif.
> a(2) -> ok.
> ----------------------------------------------------------------------
> 
> Using R8B-1.
> 
> Matthias



More information about the erlang-questions mailing list