parse transform options

Mikael Karlsson karlsson.rm@REDACTED
Wed Jul 21 04:35:23 CEST 2021


> How do you pass options (2nd argument) to a parse transform?

The options are the compile options.
If you need to pass custom options to the parse transform you can use -D :
-- test_parse.erl
-module(test_parse).
-export([parse_transform/2]).

parse_transform(Forms, Options) ->
  io:format("Options: ~p~n", [Options]),
  Forms.

-- testt.erl
-module(testt).
-export([test/0]).
-compile({parse_transform, test_parse}).

test() -> hoho.
--
~/work/erlang$ erlc -Dhejhopp -pa . testt.erl
Options: [report_warnings,
         {d,hejhopp},
         report_errors,
         {cwd,"/home/mikael/work/erlang"},
         {outdir,"/home/mikael/work/erlang"}]


More information about the erlang-questions mailing list