View mode: basic / threaded / horizontal-split · Log in · Help
August 11, 2010
Re: dmd 1.063 and 2.048 release
Module constructor is not called when it is placed in imported module, 
and WinMain is used.


module hello;

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

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

   void exceptionHandler (Throwable ex) { throw ex; }
	
   Runtime.initialize(&exceptionHandler);

   result = myWinMain();

   Runtime.terminate(&exceptionHandler);

   return result;
}

int main ()
{
  writeln (i1); // <---------------- prints "1" wich is ok.
  writeln (i2); // <---------------- prints "0" wich is incorrect.
  return 1;
}


/------

module a;

int i1 = 1;
int i2;

static this () {

   i2 = 2;
}
August 11, 2010
Re: dmd 1.063 and 2.048 release
On Wed, 11 Aug 2010 16:29:40 +0000, Michal Minich wrote:

> Module constructor is not called when it is placed in imported module,
> and WinMain is used.

Are there some changes to runtime initialization, or it is a bug? (in 
that case I will submit it).
August 11, 2010
Re: dmd 1.063 and 2.048 release
Michal Minich wrote:
> Are there some changes to runtime initialization, or it is a bug? (in 
> that case I will submit it).

You should submit it.
August 11, 2010
Re: dmd 1.063 and 2.048 release
On 8/11/2010 12:04 PM, Walter Bright wrote:
> dickl wrote:
>> static this() does not seem to be getting called, at least in D2.
>
> Works for me:
> -------------------------------
> H:\cbx>type test.d
>
> import std.stdio;
>
> void main()
> {
> printf("hello\n");
> }
>
> static this()
> {
> printf("betty\n");
> }
>
> H:\cbx>dmd test
>
> H:\cbx>test
> betty
> hello
>
> H:\cbx>

I should have been a little more clear, a static this() as a member of a 
class.
August 11, 2010
Re: dmd 1.063 and 2.048 release
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>
August 11, 2010
Re: dmd 1.063 and 2.048 release
On Wed, 11 Aug 2010 00:15:07 -0700, Walter Bright wrote:

> This is probably the last FreeBSD 7 release for D1. The next will be for
> FreeBSD 8!
> 
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.063.zip
> 
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.048.zip


This is a great release.  Bug fixes galore!

-Lars
August 11, 2010
Re: dmd 1.063 and 2.048 release
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>
hmmm doesn't for me, but works just fine in the previous rev.
August 11, 2010
Re: dmd 1.063 and 2.048 release
Lars T. Kyllingstad wrote:
> This is a great release.  Bug fixes galore!

Yup. And all these fixes are due to quite a lot of people contributing.
August 11, 2010
Re: dmd 1.063 and 2.048 release
Michal Minich Wrote:

> On Wed, 11 Aug 2010 16:29:40 +0000, Michal Minich wrote:
> 
> > Module constructor is not called when it is placed in imported module,
> > and WinMain is used.
> 
> Are there some changes to runtime initialization, or it is a bug? (in 
> that case I will submit it).

There were some changes and I must have missed updating rt_init().  Please submit a bug.  What you'll likely see is shared static ctors being called but not thread-specific (ie. non-shared) static ctors called for the main thread.
August 11, 2010
Re: dmd 1.063 and 2.048 release
On Wed, 11 Aug 2010 17:34:20 -0400, Sean Kelly wrote:

> Michal Minich Wrote:
> 
>> On Wed, 11 Aug 2010 16:29:40 +0000, Michal Minich wrote:
>> 
>> > Module constructor is not called when it is placed in imported
>> > module, and WinMain is used.
>> 
>> Are there some changes to runtime initialization, or it is a bug? (in
>> that case I will submit it).
> 
> There were some changes and I must have missed updating rt_init(). 
> Please submit a bug.  What you'll likely see is shared static ctors
> being called but not thread-specific (ie. non-shared) static ctors
> called for the main thread.

bug report:
http://d.puremagic.com/issues/show_bug.cgi?id=4622
1 2 3 4 5
Top | Discussion index | About this forum | D home