Hi there !

I have a very very little piece of code in C using the libruby, and it
crashes... I'm probably missing something but I just can't put my finger
on it.

Here's the code :
(I know, I don't finalize Ruby ^^' but I was just recoding something
that doesn't work in my app to find out if it was really coming from the
app or from the piece of code... apparently it's from the piece of code
:)

#include "ruby.h"
#include <iostream>

using namespace std;

int main(void)
{
  ruby_init();
  VALUE test = Qnil;

  test = rb_iv_get(test, "@lolwtf");
  if (test == Qnil)
    cout << "It is Qnil indeed" << endl;
  VALUE a = rb_funcall(test, rb_intern("class"), 0);
  VALUE b = rb_funcall(a,    rb_intern("to_s"),  0);

  cout << "Printing classname: " << endl;
  cout << RSTRING(b)->as.heap.ptr << endl;
  cout << "It didn't crash" << endl;
  return (0);
}

-- 
Posted via http://www.ruby-forum.com/.