-
Notifications
You must be signed in to change notification settings - Fork 1
/
niftest.erl
32 lines (26 loc) · 1004 Bytes
/
niftest.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%%%=============================================================================
%%% @doc
%%% Simple erlang NIF example taken from
%%% http://www.erlang.org/doc/man/erl_nif.html.
%%% @end
%%%=============================================================================
-module(niftest).
-export([hello/0]).
-on_load(init/0).
%%------------------------------------------------------------------------------
%% @doc
%% Returns a specific string.
%% @end
%%------------------------------------------------------------------------------
hello() ->
"NIF library not loaded".
%%------------------------------------------------------------------------------
%% @private
%%------------------------------------------------------------------------------
init() ->
case erlang:load_nif("./niftest", 0) of
ok ->
io:format("NIF library successfully loaded~n");
{error, {Reason, Text}} ->
io:format("NIF library failed to load ~p (~p)~n", [Reason, Text])
end.