Skip to content

Instantly share code, notes, and snippets.

@tsloughter
Created September 28, 2014 14:55
Show Gist options
  • Save tsloughter/5c85ff9ecfe4e80a60ec to your computer and use it in GitHub Desktop.
Save tsloughter/5c85ff9ecfe4e80a60ec to your computer and use it in GitHub Desktop.
Hello World Nif
#include "erl_nif.h"
static ERL_NIF_TERM world(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
return enif_make_string(env, "Hello world!", ERL_NIF_LATIN1);
}
static ErlNifFunc nif_funcs[] = {
{"world", 0, world}
};
ErlNifEntry* nif_init(void);
ErlNifEntry* nif_init(void) {
static ErlNifEntry entry = { 2,
6,
"hello",
sizeof(nif_funcs) / sizeof(*nif_funcs),
nif_funcs,
((void *)0),
((void *)0),
((void *)0),
((void *)0),
"beam.vanilla"
};
return &entry;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment