Skip to content

Instantly share code, notes, and snippets.

@simi
Created December 6, 2014 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simi/de7962f77585e52b8017 to your computer and use it in GitHub Desktop.
Save simi/de7962f77585e52b8017 to your computer and use it in GitHub Desktop.
minimal ruby c eval
# compile with gcc test.c `pkg-config ruby --cflags --libs` -o test.out
#include <stdio.h>
#include <ruby.h>
int main(void) {
int result;
const char code[];
ruby_init();
ruby_init_loadpath();
code = "p 'HELLO'";
rb_eval_string_protect(code, &result);
ruby_cleanup(0);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment