Skip to content

Instantly share code, notes, and snippets.

@german
Created July 4, 2012 14:42
Show Gist options
  • Save german/3047712 to your computer and use it in GitHub Desktop.
Save german/3047712 to your computer and use it in GitHub Desktop.
minimal mruby program
#include “mruby.h”
#include “mruby/proc.h”
#include <stdio.h>
void _error(const char* s){
printf("ERROR: %s\n", s);
exit(1);
}
int main() {
mrb_state *mrb;
int n;
mrb = mrb_open();
// you could also use mrb_compile_file(mrb, file_descriptor) in order to compile certain .rb files
n = mrb_compile_string(mrb, "d = lambda { puts 'Hello, World!' }; d[]");
mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_nil_value());
mrb_close(mrb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment