mix build_dot_zig.gen.c_nif (build_dot_zig v0.6.2)
View SourceInitializes a C NIF with its build system based on build.zig
.
mix build_dot_zig.gen.c_nif Math math sum/2 multiply/2
The first argument is the Elixir module that will expose the NIF, relative to the base namespace
of your app. In this case the generated module will be in lib/your_app/math.ex
and will be
called YourApp.Math
.
The second argument is the name of the NIF library. In this case the generated C file will be
src/math.c
.
The other arguments represent the functions exposed by the NIF with their arity. Empty stubs
for each of the listed functions will be generated both on the Elixir and C side. By default
the function stubs just raise a :not_implemented
error.
Functions
The functions are given using name/arity
syntax.
It's possible to pass the same function with multiple arities (e.g. sum/2
, sum/3
), in
that case on the C side there will still be only a single function and its implementation
will have to distinguish between the different arities at runtime by looking at argc
.