Thread overview
unbox!(char[]) fails with linker error.
Aug 04, 2005
Fredrik Olsson
Aug 05, 2005
Victor Nakoryakov
Aug 05, 2005
Fredrik Olsson
Aug 05, 2005
Hasan Aljudy
Aug 06, 2005
Hasan Aljudy
August 04, 2005
Hi.

This tiny test:

// !!! Begin unboxfail.d !!!
import std.boxer;
import std.stdio;

int main(char[][]args)
{
    Box b = box("Hello World");
    if (unboxable!(char[])(b)) {
        writefln(unbox!(char[])(b));    // !!! Fails !!!
        return 0;
    } else {
        return 1;
    }
}
!!! End unboxfail.d

Compiled with:
gdc unboxfail.d -o unboxfail

Gives this error message:
ld: Undefined symbols:
__init_11TypeInfo_Pv


I use gdc 0.15 installed from Anders F Björklund's package for Mac OS X. I run under Mac OS X 1.4.2.

Is there a special trick to unboxing arrays, or have I stumbled upon a bug?

regards
	Fredrik Olsson
August 05, 2005
Fredrik Olsson wrote:
> Hi.
> 
> This tiny test:
> 
> // !!! Begin unboxfail.d !!!
> import std.boxer;
> import std.stdio;
> 
> int main(char[][]args)
> {
>     Box b = box("Hello World");
>     if (unboxable!(char[])(b)) {
>         writefln(unbox!(char[])(b));    // !!! Fails !!!
>         return 0;
>     } else {
>         return 1;
>     }
> }
> !!! End unboxfail.d
> 
> Compiled with:
> gdc unboxfail.d -o unboxfail
> 
> Gives this error message:
> ld: Undefined symbols:
> __init_11TypeInfo_Pv
> 
> 
> I use gdc 0.15 installed from Anders F Björklund's package for Mac OS X. I run under Mac OS X 1.4.2.
> 
> Is there a special trick to unboxing arrays, or have I stumbled upon a bug?
> 
> regards
>     Fredrik Olsson

This is a bug and it already added to DStress.

-- 
Victor (aka nail) Nakoryakov
nail-mail<at>mail<dot>ru

Krasnoznamensk, Moscow, Russia
August 05, 2005
Victor Nakoryakov wrote:
> Fredrik Olsson wrote:
> 
>> Hi.
>>
>> This tiny test:
>>
>> // !!! Begin unboxfail.d !!!
>> import std.boxer;
>> import std.stdio;
>>
>> int main(char[][]args)
>> {
>>     Box b = box("Hello World");
>>     if (unboxable!(char[])(b)) {
>>         writefln(unbox!(char[])(b));    // !!! Fails !!!
>>         return 0;
>>     } else {
>>         return 1;
>>     }
>> }
>> !!! End unboxfail.d
>>
>> Compiled with:
>> gdc unboxfail.d -o unboxfail
>>
>> Gives this error message:
>> ld: Undefined symbols:
>> __init_11TypeInfo_Pv
>>
>>
>> I use gdc 0.15 installed from Anders F Björklund's package for Mac OS X. I run under Mac OS X 1.4.2.
>>
>> Is there a special trick to unboxing arrays, or have I stumbled upon a bug?
>>
>> regards
>>     Fredrik Olsson
> 
> 
> This is a bug and it already added to DStress.
> 
Good.

Is there a work-around that can be used in the mean time (I need to box and unbox int, float, char[] and my own class Block and it's decendant ContainerBlock only).

Regards
	Fredrik Olsson
August 05, 2005
Fredrik Olsson wrote:
> Victor Nakoryakov wrote:
> 
>> Fredrik Olsson wrote:
>>
>>> Hi.
>>>
>>> This tiny test:
>>>
>>> // !!! Begin unboxfail.d !!!
>>> import std.boxer;
>>> import std.stdio;
>>>
>>> int main(char[][]args)
>>> {
>>>     Box b = box("Hello World");
>>>     if (unboxable!(char[])(b)) {
>>>         writefln(unbox!(char[])(b));    // !!! Fails !!!
>>>         return 0;
>>>     } else {
>>>         return 1;
>>>     }
>>> }
>>> !!! End unboxfail.d
>>>
>>> Compiled with:
>>> gdc unboxfail.d -o unboxfail
>>>
>>> Gives this error message:
>>> ld: Undefined symbols:
>>> __init_11TypeInfo_Pv
>>>
>>>
>>> I use gdc 0.15 installed from Anders F Björklund's package for Mac OS X. I run under Mac OS X 1.4.2.
>>>
>>> Is there a special trick to unboxing arrays, or have I stumbled upon a bug?
>>>
>>> regards
>>>     Fredrik Olsson
>>
>>
>>
>> This is a bug and it already added to DStress.
>>
> Good.
> 
> Is there a work-around that can be used in the mean time (I need to box and unbox int, float, char[] and my own class Block and it's decendant ContainerBlock only).
> 
> Regards
>     Fredrik Olsson


I would assume you can write something like this:
<code>
class StringBox
{
	this( char str[] )
	{
	// .. do something to encapsulate str into this object
	}
}



Box x = ( new StringBox("HelloWorld") );
</code>
i.e. write a small class or struct that hides the string, and then box that class and unbox it.
August 06, 2005
Hasan Aljudy wrote:
> Fredrik Olsson wrote:
> 
>> Victor Nakoryakov wrote:
>>
>>> Fredrik Olsson wrote:
>>>
>>>> Hi.
>>>>
>>>> This tiny test:
>>>>
>>>> // !!! Begin unboxfail.d !!!
>>>> import std.boxer;
>>>> import std.stdio;
>>>>
>>>> int main(char[][]args)
>>>> {
>>>>     Box b = box("Hello World");
>>>>     if (unboxable!(char[])(b)) {
>>>>         writefln(unbox!(char[])(b));    // !!! Fails !!!
>>>>         return 0;
>>>>     } else {
>>>>         return 1;
>>>>     }
>>>> }
>>>> !!! End unboxfail.d
>>>>
>>>> Compiled with:
>>>> gdc unboxfail.d -o unboxfail
>>>>
>>>> Gives this error message:
>>>> ld: Undefined symbols:
>>>> __init_11TypeInfo_Pv
>>>>
>>>>
>>>> I use gdc 0.15 installed from Anders F Björklund's package for Mac OS X. I run under Mac OS X 1.4.2.
>>>>
>>>> Is there a special trick to unboxing arrays, or have I stumbled upon a bug?
>>>>
>>>> regards
>>>>     Fredrik Olsson
>>>
>>>
>>>
>>>
>>> This is a bug and it already added to DStress.
>>>
>> Good.
>>
>> Is there a work-around that can be used in the mean time (I need to box and unbox int, float, char[] and my own class Block and it's decendant ContainerBlock only).
>>
>> Regards
>>     Fredrik Olsson
> 
> 
> 
> I would assume you can write something like this:
> <code>
> class StringBox
> {
>     this( char str[] )
>     {
>     // .. do something to encapsulate str into this object
>     }
> }
> 
> 
> 
> Box x = ( new StringBox("HelloWorld") );
> </code>
> i.e. write a small class or struct that hides the string, and then box that class and unbox it.
woops, I meant:
#Box b = box( new StringBox("HelloWorld") );