Problems with rb_struct_define and 64 bit Ruby

Hi all,

Ruby 1.8.4, 64 bit, built with --enable-pthread - no other special options
Suse Linux 9.3

It's late and I'm tired, so maybe I'm doing something dumb here, but this
code segfaults:

/* foo.c */
#include "ruby.h"
VALUE v_my_struct;

void Init_foo(){
   v_my_struct =
      rb_struct_define("MyStruct", "fee", "fi", "fo", "alpha", "beta",
"gamma", 0);
}

# extconf.rb
require 'mkmf'
create_makefile('foo')

# test.rb
$:.unshift Dir.pwd
require 'foo'

Take away any one member, and it works. Any more than five and it
segfaults. What gives?

Thanks,

Dan

      rb_struct_define("MyStruct", "fee", "fi", "fo", "alpha", "beta",
"gamma", 0);

   ^^^^^^^^^^

   "gamma", NULL);

}

  ...

Guy Decoux

Gah. That's one of the things that I absolutely *despise* about C as
opposed to C++. I *like* that I can use 0 as if it were the same thing
as NULL and not (void*)0.

-austin

···

On 6/8/06, ts <decoux@moulon.inra.fr> wrote:

> rb_struct_define("MyStruct", "fee", "fi", "fo", "alpha", "beta",
> "gamma", 0);

   ^^^^^^^^^^

   "gamma", NULL);

> }

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Gah. That's one of the things that I absolutely *despise* about C as
opposed to C++. I *like* that I can use 0 as if it were the same thing
as NULL and not (void*)0.

Well, the architecture x86_64 was created to make in sort that C
programmer understand the difference between (int)0 and (void *)0

:slight_smile:

Guy Decoux