Thread overview
Remove libphobos dependency
Jul 12, 2008
Vincent Richomme
Jul 12, 2008
Lars Ivar Igesund
Jul 12, 2008
Vincent Richomme
Jul 12, 2008
e-t172
Jul 13, 2008
Vincent Richomme
Jul 13, 2008
Vincent Richomme
Jul 14, 2008
David Friedman
July 12, 2008
Hi,

I am interested in D language but libphobos library is far from being portable and development is too slow.
I would like to know how can I remove libphobos dependecy because from what I see now I cannot compile a simple example without it.




Thanks
July 12, 2008
Vincent Richomme wrote:

> Hi,
> 
> I am interested in D language but libphobos library is far from being
> portable and development is too slow.
> I would like to know how can I remove libphobos dependecy because from
> what I see now I cannot compile a simple example without it.
> 
> 
> 
> 
> Thanks

Look to Tango?

http://www.dsource.org/projects/tango

As for GDC specific, see the --nostdlib switch or something along those lines.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
July 12, 2008
Lars Ivar Igesund a écrit :
> Vincent Richomme wrote:
> 
>> Hi,
>>
>> I am interested in D language but libphobos library is far from being
>> portable and development is too slow.
>> I would like to know how can I remove libphobos dependecy because from
>> what I see now I cannot compile a simple example without it.
>>
>>
>>
>>
>> Thanks
> 
> Look to Tango?
> 
> http://www.dsource.org/projects/tango
> 
> As for GDC specific, see the --nostdlib switch or something along those
> lines.
> 

Sounds interesting buf in a first step I would like no lib.
I just want to display a message box on a wince platform.

There's something I don't understand with D language , I can see that on a sample given here http://www.digitalmars.com/d/2.0/index.html

#!/usr/bin/dmd -run


import std.stdio;

void main(string[] args)
{
   ....

}


but when I look ar D for win32 I can see this :

import std.c.windows.windows;

extern (C) void gc_init();
extern (C) void gc_term();
extern (C) void _minit();
extern (C) void _moduleCtor();
extern (C) void _moduleDtor();
extern (C) void _moduleUnitTests();

extern (Windows)
int WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
    int result;

    gc_init();			// initialize garbage collector
    _minit();			// initialize module constructor table

    try
    {
	_moduleCtor();		// call module constructors
	_moduleUnitTests();	// run unit tests (optional)

	result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);

	_moduleDtor();		// call module destructors
    }

    catch (Object o)		// catch any uncaught exceptions
    {
	MessageBoxA(null, cast(char *)o.toString(), "Error",
		    MB_OK | MB_ICONEXCLAMATION);
	result = 0;		// failed
    }

    gc_term();			// run finalizers; terminate garbage collector
    return result;
}

int myWinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
    /* ... insert user code here ... */
}

In this second example there are lots of code about garbage collection (gc_init, ...)while in the first sample there are not.
Does it mean on windows we always have to call gc_init ? Is it specific to Windows platform , GDC compiler or libphobos lib ?

Last question about auto keyword, does it mean variable is handled by garbage collector :

foreach (argc, argv; args)
    {
        // Object Oriented Programming
        auto cl = new CmdLin(argc, argv);
        // Improved typesafe printf
        writeln(cl.argnum, cl.suffix, " arg: ", cl.argv);
        // Automatic or explicit memory management
        delete cl;
    }


in the code below I don't understand why to declare auto if then it is destroyed manually ...









July 12, 2008
Lars Ivar Igesund a écrit :
> As for GDC specific, see the --nostdlib switch or something along those
> lines.

It's -nophoboslib, actually.
July 13, 2008
e-t172 a écrit :
> Lars Ivar Igesund a écrit :
>> As for GDC specific, see the --nostdlib switch or something along those
>> lines.
> 
> It's -nophoboslib, actually.

In which file should I add this parameter ?
July 13, 2008
Vincent Richomme a écrit :
> e-t172 a écrit :
>> Lars Ivar Igesund a écrit :
>>> As for GDC specific, see the --nostdlib switch or something along those
>>> lines.
>>
>> It's -nophoboslib, actually.
> 
> In which file should I add this parameter ?
Hum maybe you mean when calling gdc compiler.

July 14, 2008
Vincent Richomme wrote:
> Vincent Richomme a écrit :
>> e-t172 a écrit :
>>> Lars Ivar Igesund a écrit :
>>>> As for GDC specific, see the --nostdlib switch or something along those
>>>> lines.
>>>
>>> It's -nophoboslib, actually.
>>
>> In which file should I add this parameter ?
> Hum maybe you mean when calling gdc compiler.
> 

-nophoboslib in the link command is the way to go.  This lets you link against libgcc without having the link libgphobos and the the system pthread libraries.

If you are using the GNU linker, you can also reduce link dependencies by compiling with -ffunction-sections and -fdata-sections and then link with -Wl,-gc-sections.