dmd 1.063 and 2.048 release

dickl dick221z at yahoo.com
Thu Aug 12 21:04:54 PDT 2010


On 8/12/2010 11:46 PM, Yao G. wrote:
> On Thu, 12 Aug 2010 22:09:40 -0500, dickl <dick221z at yahoo.com> wrote:
>
>> 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");
>> }
>> }
>>
>>
>
> You are mixing windows specific functions (WinMain) and console
> functions (writeln). This will either cause an exception or just fail to
> run. Try to replace calls to writeln with calls to MessageBox if you
> want to check if the static constructor/destructor is working correctly.
>
The point is the static if isn't getting called at all...
and writeln does work in this example...


More information about the Digitalmars-d-announce mailing list