[erlang-questions] why does the preprocessor sometimes care about -ifdef'd out code?

Matthias Lang matthias@REDACTED
Thu Mar 8 18:27:50 CET 2007


Hi,

A co-worker asked me: Why does this module not compile?

    -module(mod1).
    -ifdef(X).
    f,
    -endif.

tmp >erlc -Wall mod1.erl 
./mod1.erl:5: unterminated '-ifdef'

Whereas this module does:

   -module(mod1).
   -ifdef(X).
   f.
   -endif.

even though this module doesn't:

   -module(mod1).
   f,

and this module doesn't either:

   -module(mod1).
   f.

(I know the erlang preprocessor behaves differently to, say, C, but I
can't explain the above.)

Matthias



More information about the erlang-questions mailing list