Packages

A semi-useful tool to generate boilerplate when you want to use a NIF in your project. You don't really want to use a NIF in your project, until you do. Then this might save you writing most of the boilerplate.

Current section

Files

Jump to
nifty lib nif.ex
Raw

lib/nif.ex

defmodule NIF do
# When your move/rename this file (and you should) make sure
# you also change the ERL_NIF_INIT call at the bottom of
# c_src/hello_nif.c
@on_load :init
def init do
:erlang.load_nif("./priv/lib/lib_hello", 0)
end
# A simple wrapper around the NIF call
def hello do
_hello
end
# This function will not be overwritten if the nif fails to load
def _hello do
"NIF library not loaded"
end
end