# Problems with rb\_struct\_define and 64 bit Ruby

**URL:** <https://www.ruby-forum.com/t/problems-with-rb-struct-define-and-64-bit-ruby/62799>\
**Category:** Ruby\
**Created:** [June 8, 2006, 7:04am UTC](https://www.ruby-forum.com/t/problems-with-rb-struct-define-and-64-bit-ruby/62799 "2006-06-08T07:04:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 8, 2006, 7:04am UTC](https://www.ruby-forum.com/t/problems-with-rb-struct-define-and-64-bit-ruby/62799/1 "2006-06-08T07:04:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 8, 2006, 9:23am UTC](https://www.ruby-forum.com/t/problems-with-rb-struct-define-and-64-bit-ruby/62799/2 "2006-06-08T09:23:24Z")

</div>

> > > > > “D” == Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

D\> rb\_struct\_define(“MyStruct”, “fee”, “fi”, “fo”, “alpha”,  
“beta”,  
D\> “gamma”, 0);

^^^^^^^^^^

“gamma”, NULL);

D\> }

…

Guy Decoux

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 8, 2006, 11:52pm UTC](https://www.ruby-forum.com/t/problems-with-rb-struct-define-and-64-bit-ruby/62799/3 "2006-06-08T23:52:57Z")

</div>

On 6/8/06, ts [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > > > “D” == Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
> > > > > > D\> rb\_struct\_define(“MyStruct”, “fee”, “fi”, “fo”, “alpha”, “beta”,  
> > > > > > D\> “gamma”, 0);
> 
> ^^^^^^^^^^
> 
> “gamma”, NULL);
> 
> D\> }

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

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [June 9, 2006, 10:00am UTC](https://www.ruby-forum.com/t/problems-with-rb-struct-define-and-64-bit-ruby/62799/4 "2006-06-09T10:00:29Z")

</div>

> > > > > “A” == Austin Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

A\> Gah. That’s one of the things that I absolutely _despise_ about C as  
A\> opposed to C++. I _like_ that I can use 0 as if it were the same  
thing  
A\> 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

🙂

Guy Decoux
