Remove libphobos dependency

Vincent Richomme forumer at smartmobili.com
Sat Jul 12 04:44:07 PDT 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 ...











More information about the D.gnu mailing list