Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.49 KB | None | 0 0
  1.   #include <stdio.h>
  2.   #include "janet.h"
  3.  
  4.   static Janet myfun(int32_t argc, Janet *argv) {
  5.     janet_fixarity(argc, 0);
  6.     printf("hello from a module!\n");
  7.  
  8.     return janet_wrap_nil();
  9.   }
  10.  
  11.   static const JanetReg cfuns[] = {
  12.     {"myfun", myfun, "(mymod/myfun)\n\nPrints a hello message."},
  13.     {NULL, NULL, NULL}
  14.   };
  15.  
  16.   int main() {
  17.     puts("Hello from main!");
  18.     janet_init();
  19.  
  20.     JanetTable *env = janet_core_env(NULL);
  21.                                                                                                                                                                                                                                              
  22.     janet_cfuns(env, "mymod", cfuns);
  23.     janet_dostring(env, "(mymod/myfun)", "main", NULL);
  24.     janet_deinit();                                                                                                                                                                                                                          
  25.                                                                                                                                                                                                                                              
  26.     return 0;                                                                                                                                                                                                                                
  27.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement