Erlang R15B added ErlDrvSSizeT typedef, and R16B added erl_drv_output_term function and deprecated the old equivalent. Is there a way to test for these differences with preprocessor macros in order to support older Erlang versions with the same code?
Are there macros which can be used to test Erlang version in driver C code?
168 Views Asked by Alexey Romanov At
1
You can use the
ERL_DRV_EXTENDED_MAJOR_VERSIONandERL_DRV_EXTENDED_MINOR_VERSIONmacro values, supplied inerl_driver.h, to make decisions about features. Whenever the driver API changes, these values are suitably incremented. These increments are always explained in the Erlang/OTP release notes.For example, Erlang/OTP R15B changed some API function parameter types from
intto a new typeErlDrvSizeTto better cope with 64-bit platforms. You can test for this and compensate for it for older pre-R15B versions using the code below:This typedef allows you to use the type
ErlDrvSizeTeven for older driver versions.As of this writing, Erlang/OTP version 17.3 and version 6.2 of the Erlang runtime system (erts) are current. For erts 6.2,
ERL_DRV_EXTENDED_MAJOR_VERSIONandERL_DRV_EXTENDED_MINOR_VERSIONhave the values 3 and 1, respectively. The changes in this Erlang/OTP commit created these version values.