[erlang-questions] Can i share nif resource between two nif module?
Mon Dec 26 22:28:24 CET 2016
On Mon, Dec 26, 2016 at 1:41 PM, Ildar Khizbulin <>
> Yep, including. I create simple example on
> https://github.com/hizel/enif_test with full code.
What you're trying to do doesn't appear to be supported currently. The
Erlang nif internals require the module name argument (second argument) of
enif_open_resource_type() to be a null pointer (see
generates an atom identifier for the resource type based on the calling
module. You can see that code here:
As a result, when your second module tries to take over the resource type,
the enif_open_resource_type() implementation fails to find the resource you
created in your first module, and so it ends up creating a new resource
type instead. When you try to use this new type in your second module to
retrieve the resource binary argument created by the first module, you get
badarg because the two resource types are different types.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions