Created
December 6, 2014 08:46
-
-
Save simi/de7962f77585e52b8017 to your computer and use it in GitHub Desktop.
minimal ruby c eval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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