[erlang-questions] Compilation question...
Tue Jan 30 16:00:05 CET 2007
Emil Hellman wrote:
> I have a small feature I want to several modules. My thought is to add
> this feature if I encounter a '-myfeature(Args)' in the module.
> Where args could be several different things.
> So essentially if I find this "tag" in the module I would like to
> append some code to the file (dependant on the args). And then compile
> the modified module. However, I don't want the generated code to be
> appended to the actual module, simply added temporarily during the
> To do this I need some guidance. What module(s) contain the code that
> is used by the compiler? I checked out 'compile.erl', but I think I
> want to do something to the modules before this code is called (though
> I might be wrong here).
If you do not want to use a parse transform you can try to use an
include directive and the preprocessor to solve your problem. It would
look something like this:
and in myfeature.hrl:
Code to append using ?ARGS
This of course less versatile than a parse transform, but it is easier
More information about the erlang-questions