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

**URL:** <https://rubytalk.org/t/problems-with-rb-struct-define-and-64-bit-ruby/28070>\
**Category:** ruby-talk\
**Created:** [8 June 2006 05:02 UTC](https://rubytalk.org/t/problems-with-rb-struct-define-and-64-bit-ruby/28070 "2006-06-08T05:02:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)\
**Post date:** [8 June 2006 05:02 UTC](https://rubytalk.org/t/problems-with-rb-struct-define-and-64-bit-ruby/28070/1 "2006-06-08T05:02:47Z")

</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(){  
&nbsp;&nbsp;&nbsp;v\_my\_struct =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [8 June 2006 07:20 UTC](https://rubytalk.org/t/problems-with-rb-struct-define-and-64-bit-ruby/28070/2 "2006-06-08T07:20:54Z")

</div>

> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rb\_struct\_define("MyStruct", "fee", "fi", "fo", "alpha", "beta",  
> "gamma", 0);

&nbsp;&nbsp;&nbsp;^^^^^^^^^^

&nbsp;&nbsp;&nbsp;"gamma", NULL);

> }

&nbsp;&nbsp;...

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Austin\_Ziegler5](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/austin_ziegler5/32/1985_2.png) [@Austin\_Ziegler5](https://rubytalk.org/u/Austin_Ziegler5)\
**Post date:** [8 June 2006 21:52 UTC](https://rubytalk.org/t/problems-with-rb-struct-define-and-64-bit-ruby/28070/3 "2006-06-08T21:52:01Z")

</div>

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);
> > 
> > &nbsp;&nbsp;&nbsp;^^^^^^^^^^
> > 
> > &nbsp;&nbsp;&nbsp;"gamma", NULL);
> > 
> > \> }
> 
> --  
> Austin Ziegler \* halostatue@gmail.com  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Alternate: austin@halostatue.ca

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [9 June 2006 07:58 UTC](https://rubytalk.org/t/problems-with-rb-struct-define-and-64-bit-ruby/28070/4 "2006-06-09T07:58:01Z")

</div>

> 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

🙂

Guy Decoux
