dmd 1.063 and 2.048 release

dickl dick221z at yahoo.com
Thu Aug 12 20:09:40 PDT 2010


On 8/11/2010 1:09 PM, Walter Bright wrote:
> dickl wrote:
>> I should have been a little more clear, a static this() as a member of
>> a class.
>
> Still works:
> --------------------------
>
> H:\cbx>type test.d
>
> import std.stdio;
>
> void main()
> {
> printf("hello\n");
> }
>
> class C
> {
> static this()
> {
> printf("betty\n");
> }
> }
>
>
> H:\cbx>dmd test
>
> H:\cbx>test
> betty
> hello
>
> H:\cbx>

Looks like it might be windows specific. This doesn't work (only prints 
out "again"


import std.stdio;
import std.string;
import std.c.windows.windows;
import core.runtime;


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

     try
     {
         Runtime.initialize();
         return myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);


	}//end try

     catch (Object o)		// catch any uncaught exceptions
     {
		MessageBoxA(null, toStringz(o.toString()), "Fatal Error", MB_OK | 
MB_ICONERROR);
     }finally
     {
         Runtime.terminate();
     }


     return 0;
}//end int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR 
lpCmdLine,int nCmdShow)


int myWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR 
lpCmdLine, int nCmdShow)
{

		foo f = new foo;
	
		return 1;
}//end int myWinMain HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR 
lpCmdLine, int nCmdShow)


class foo
{
public:
	static this()
	{
		writeln("Hello");
	}
	static ~this()
      {
	}
	this()
	{
		writefln(" again");
	}
}




More information about the Digitalmars-d-announce mailing list