[erlang-questions] App supporting several Erlang releases

Jachym Holecek freza@REDACTED
Mon Jan 17 20:22:21 CET 2011


# Vlad Dumitrescu 2011-01-17:
> I have some code that I'd like to be able to run in R12 or later, depending
> on what the user has installed. The problem is that some OTP APIs have
> changed in R13 and R14, making the task not straightforward. Unfortunately
> it's not only code that is affected (that would be possible to fix by
> checking the actual version), but also hrl files have moved or been created
> in the meanwhile. The most acute example is about eunit, where for example
> in R13 eunit.hrl moved from eunit/src to eunit/include and the
> eunit_listener behaviour was added.
> 
> Is there any way to address this in a more reasonable way than duplicating
> the affected module and fiddling with the code path at load time?

IIRC what a colleague did some time ago to solve similar problem was
to extract OTP release from ${prefix}/lib/erlang/releases/RELEASES
(or was it ERTS version? -- they're both there anyway) and use that
to define a macro from erlc commandline, then add ifdefs to affected
files that would include headers from the right location. I'm not
sure this was actually used in the end, but it worked.

So -- depends on your build system and the amount of dark trickery
you're willing to tolerate in your codebase :-).

Regards,
	-- Jachym


More information about the erlang-questions mailing list