# Struct needs to be a constant?

**URL:** <https://rubytalk.org/t/struct-needs-to-be-a-constant/1076>\
**Category:** ruby-talk\
**Created:** [8 August 2002 14:10 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076 "2002-08-08T14:10:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berger\_Daniel2](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Berger\_Daniel2](https://rubytalk.org/u/Berger_Daniel2)\
**Post date:** [8 August 2002 14:10 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/1 "2002-08-08T14:10:09Z")

</div>

> From: ts [[mailto:decoux@moulon.inra.fr](mailto:decoux@moulon.inra.fr)]  
> Sent: Thursday, August 08, 2002 8:08 AM  
> To: [ruby-talk@ruby-lang.org](mailto:ruby-talk@ruby-lang.org)  
> Cc: [ruby-talk@ruby-lang.org](mailto:ruby-talk@ruby-lang.org)  
> Subject: Re: struct needs to be a constant?

> > > rb\_struct\_define(“Proto::ProtoStruct”,“name”,“aliases”,“number”,0);  
> > > ^^^^^^^^^^^^^^^^^^^^  
> > > ^^  
> > > ^^
> 
> This is this that 1.7 don’t like, and I understand it.

I’m not sure what mean here (I’m having difficulty translating). Are you  
saying that this is expected behavior and that you agree with it?

> > > > void Init\_proto()  
> > > > ^^^^^  
> > > > ^^^^^
> 
> Now nobody can write an extension with the name `proto’, even if your  
> extension is called via ‘require “net/proto”’ ☹

Not true, at least not if I understand you correctly. With my own version  
of Net::Proto already installed, I wrote this and installed it:

#include “ruby.h”  
#include \<stdio.h\>

void Init\_proto()  
{  
VALUE t\_mTest, cTest;  
t\_mTest = rb\_define\_module(“Test”);  
cTest = rb\_define\_class\_under(t\_mTest,“Proto”,rb\_cObject);

printf(“Yes, this extension works, even though it’s called ‘Proto’\n”);  
}

In the extconf.rb I did this:

require “mkmf”  
create\_makefile(‘test/proto’)

Then I did:

require “net/proto”  
require “test/proto”

It seemed to work fine. Have I missed something?

Regards,

Dan

> **···**
>
> > -----Original Message-----

---

<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 August 2002 14:15 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/2 "2002-08-08T14:15:37Z")

</div>

> > This is this that 1.7 don't like, and I understand it.

> I'm not sure what mean here (I'm having difficulty translating). Are you  
> saying that this is expected behavior and that you agree with it?

Yes expected behavior and yes I agree with it : you have strange  
characters "::" in the name of the constant

> Not true, at least not if I understand you correctly. With my own version  
> of Net::Proto already installed, I wrote this and installed it:

Well, personnaly I'll not trust this because you have defined \*twice\* the  
function Init\_proto()

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [8 August 2002 15:38 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/3 "2002-08-08T15:38:51Z")

</div>

Hi,

> **···**
>
> At Thu, 8 Aug 2002 23:15:37 +0900, ts wrote:
> 
> > > Not true, at least not if I understand you correctly. With my own version  
> > > of Net::Proto already installed, I wrote this and installed it:
> > 
> > Well, personnaly I’ll not trust this because you have defined _twice_ the  
> > function Init\_proto()
> 
> They are in different modules, and names from extension  
> libraries are not exported to others by default, unless one was  
> linked with another.
> 
> –  
> Nobu Nakada

---

<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 August 2002 08:02 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/4 "2002-08-09T08:02:19Z")

</div>

> They are in different modules, and names from extension  
> libraries are not exported to others by default, unless one was  
> linked with another.

And if someone want to have a static version of ruby with these libraries,  
how he do this ?

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [9 August 2002 09:25 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/5 "2002-08-09T09:25:09Z")

</div>

Hi,

> **···**
>
> At Fri, 9 Aug 2002 17:02:19 +0900, ts wrote:
> 
> > > They are in different modules, and names from extension  
> > > libraries are not exported to others by default, unless one was  
> > > linked with another.
> > 
> > And if someone want to have a static version of ruby with these libraries,  
> > how he do this ?
> 
> I see. The issue would need discussion. How do you consider?
> 
> –  
> Nobu Nakada

---

<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 August 2002 09:28 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/6 "2002-08-09T09:28:26Z")

</div>

> I see. The issue would need discussion. How do you consider?

No good idea, actually. but try to compile a static version of ruby with  
tk and you'll see that actually it exist a problem.

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [10 August 2002 09:10 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/7 "2002-08-10T09:10:58Z")

</div>

Hi,

> > I see. The issue would need discussion. How do you consider?
> 
> No good idea, actually.

What about searching Init\_“feature”() function first? If it  
failed, search Init\_“basename”() function as now.

> but try to compile a static version of ruby with  
> tk and you’ll see that actually it exist a problem.

Hmmm, I’m not sure but do you mean the difference between the  
directory name “tk” and the module name “tkutil”?

> **···**
>
> At Fri, 9 Aug 2002 18:28:26 +0900, ts wrote:
> 
> –  
> Nobu Nakada

---

<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:** [10 August 2002 11:43 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/8 "2002-08-10T11:43:58Z")

</div>

> Hmmm, I'm not sure but do you mean the difference between the  
> directory name "tk" and the module name "tkutil"?

Yes, this is this case

&nbsp;&nbsp;static version of ruby

pigeon% ldd ruby  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not a dynamic executable  
pigeon%

ruby has registered "tk"

pigeon% ./ruby -e 'p $"'  
["curses", "dbm", "digest", "dl", "etc", "fcntl", "gdbm", "iconv", "nkf",  
"pty", "readline", "sdbm", "socket", "stringio", "strscan", "syslog",  
"tcltklib", "tk", "digest/md5", "digest/rmd160", "digest/sha1",  
"digest/sha2", "racc/cparse"]  
pigeon%

but it try to load 'tkutil.so'

pigeon% ./ruby -rtk -e 1  
/home/ts/local/r17/lib/ruby/1.7/tk.rb:8:in `require': No such file to load -- tkutil (LoadError)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /home/ts/local/r17/lib/ruby/1.7/tk.rb:8  
pigeon%

it has generated

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Init\_tkutil();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rb\_provide("tk");

I have not yet understood this case, where, apparently, the user request  
for an extension but ruby try to load another extension

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [10 August 2002 13:25 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/9 "2002-08-10T13:25:45Z")

</div>

Hi,

> **···**
>
> At Sat, 10 Aug 2002 20:43:58 +0900, ts wrote:
> 
> > it has generated
> > 
> > ```
> > Init_tkutil();
> > rb_provide("tk");
> > 
> > ```
> > 
> > I have not yet understood this case, where, apparently, the user request  
> > for an extension but ruby try to load another extension
> 
> In this case, I guess extmk.rb.in should be fixed.
> 
> # Index: extmk.rb.in
> 
> RCS file: /cvs/ruby/src/ruby/ext/extmk.rb.in,v  
> retrieving revision 1.79  
> diff -u -2 -p -r1.79 extmk.rb.in  
> — extmk.rb.in 29 Jul 2002 07:06:34 -0000 1.79  
> +++ extmk.rb.in 10 Aug 2002 13:17:58 -0000  
> @@ -803,5 +803,5 @@ if $extlist.size \> 0  
> \tInit\_%s();\n  
> \trb\_provide("%s");\n  
> -“, t, s)  
> +”, t, t)  
> $extobjs += “ext/”  
> $extobjs += f
> 
> –  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![Yukihiro\_Matsumoto2](https://avatars.discourse-cdn.com/v4/letter/y/b9e5f3/32.png) [@Yukihiro\_Matsumoto2](https://rubytalk.org/u/Yukihiro_Matsumoto2)\
**Post date:** [10 August 2002 15:48 UTC](https://rubytalk.org/t/struct-needs-to-be-a-constant/1076/10 "2002-08-10T15:48:02Z")

</div>

Hi,

> **···**
>
> In message “Re: struct needs to be a constant?” on 02/08/10, [nobu.nokada@softhome.net](mailto:nobu.nokada@softhome.net) [nobu.nokada@softhome.net](mailto:nobu.nokada@softhome.net) writes:
> 
> > > ```
> > > Init_tkutil();
> > > rb_provide("tk");
> > > 
> > > ```
> > > 
> > > I have not yet understood this case, where, apparently, the user request  
> > > for an extension but ruby try to load another extension
> > 
> > In this case, I guess extmk.rb.in should be fixed.
> 
> Yes, but in a different manner. $static should be updated if $target  
> is modified in extconf.rb.
> 
> ```
> matz.
> 
> ```
