[erlang-questions] Macro expansion

Richard Carlsson richardc@REDACTED
Fri Aug 14 10:27:07 CEST 2009


Chandru wrote:
> Hi all,
> 
> I need some help with passing command line parameters to the compiler.
> 
> I have some macros in a module. I want to be able to pass the value for
> these macros at compile time as command line parameters. I'm using Makefiles
> which invoke 'erl -make'. How do I pass these macro values so that the
> compiler is able to extract them and compile the module?

>From the documentation of make (the erlang module):

  the following Emakefile means that file1 shall be compiled with the
  options [debug_info,{i,"../foo"}], while all other files in the
  current directory shall be compiled with only the debug_info flag.

  {'file1',[debug_info,{i,"../foo"}]}.
  {'*',[debug_info]}.

And from the documentation of the 'compile' module:

  {d,Macro}
  {d,Macro,Value}
  Defines a macro Macro to have the value Value. The default is true).

    /Richard


More information about the erlang-questions mailing list