Skip to content

Instantly share code, notes, and snippets.

@djberg96
Last active November 30, 2020 18:21
Show Gist options
  • Select an option

  • Save djberg96/b5ad384d91d325d846290c361fcde81f to your computer and use it in GitHub Desktop.

Select an option

Save djberg96/b5ad384d91d325d846290c361fcde81f to your computer and use it in GitHub Desktop.
#include "ruby.h"
VALUE cBar;
struct stuff_struct {
int age;
int data[];
};
static VALUE bar_foo(VALUE self){
static struct stuff_struct s = {50, {1, 2, 3}};
//v_array = rb_ary_new4(sizeof(s.data), (VALUE*)s.data);
printf("Age: %i\n", s.age);
printf("Data: %i\n", s.data[2]);
return self;
}
void Init_bar(){
cBar = rb_define_class("Bar", rb_cObject);
rb_define_method(cBar, "foo", bar_foo, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment