View mode: basic / threaded / horizontal-split · Log in · Help
August 12, 2010
Re: dmd 1.063 and 2.048 release
Works for me as well. 2.048 @ Win32.

dickl 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>
> hmmm doesn't for me, but works just fine in the previous rev.
August 12, 2010
Re: dmd 1.063 and 2.048 release
"Walter Bright" <newshound2@digitalmars.com> wrote in message 
news:i3v36f$1d81$1@digitalmars.com...
> 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.

...and a 2-month development cycle instead of the usual approx one month. 
**Not that I'm complaining, or being impatient, or trying to belittle the 
contributions!!** Just an observation!!!
August 12, 2010
Re: dmd 1.063 and 2.048 release
Thanks everybody for the hard work, good release!
August 13, 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>

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");
	}
}
August 13, 2010
Re: dmd 1.063 and 2.048 release
On Thu, 12 Aug 2010 22:09:40 -0500, dickl <dick221z@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.

-- 
Yao G.
August 13, 2010
Re: dmd 1.063 and 2.048 release
On 8/12/2010 11:46 PM, Yao G. wrote:
> On Thu, 12 Aug 2010 22:09:40 -0500, dickl <dick221z@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...
August 13, 2010
Re: dmd 1.063 and 2.048 release
On Thu, 12 Aug 2010 23:04:54 -0500, dickl <dick221z@yahoo.com> wrote:

> On 8/12/2010 11:46 PM, Yao G. wrote:
>> 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...

Try using:

shared static this()

I had a similar problem with a Win32 wrapper that I did.

-- 
Yao G.
August 13, 2010
Re: dmd 1.063 and 2.048 release
dickl wrote:
> 
> Looks like it might be windows specific. This doesn't work (only prints 
> out "again"
>
> 
> extern (Windows) int WinMain(HINSTANCE hInstance,HINSTANCE 
> hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
> {

FYI, if you didn't already know, you can avoid WinMain entirely and just 
use a regular main function and still get a windowed app with no 
console. Just pass the following command line option to DMD:

-L/SUBSYSTEM:windows:5

And you can replace the 5 with a 4 if you want to support Win 9x.
August 13, 2010
Re: dmd 1.063 and 2.048 release
On 8/13/2010 4:28 AM, Mike Parker wrote:
> dickl wrote:
>>
>> Looks like it might be windows specific. This doesn't work (only
>> prints out "again"
>>
>>
>> extern (Windows) int WinMain(HINSTANCE hInstance,HINSTANCE
>> hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
>> {
>
> FYI, if you didn't already know, you can avoid WinMain entirely and just
> use a regular main function and still get a windowed app with no
> console. Just pass the following command line option to DMD:
>
> -L/SUBSYSTEM:windows:5
>
> And you can replace the 5 with a 4 if you want to support Win 9x.

This is just a test example to cut the code size down. It not a 
representation of the application.
August 13, 2010
Re: dmd 1.063 and 2.048 release
On 8/13/2010 12:20 AM, Yao G. wrote:
> On Thu, 12 Aug 2010 23:04:54 -0500, dickl <dick221z@yahoo.com> wrote:
>
>> On 8/12/2010 11:46 PM, Yao G. wrote:
>>> 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...
>
> Try using:
>
> shared static this()
>
> I had a similar problem with a Win32 wrapper that I did.
>

using shared works

tnx
1 2 3 4 5
Top | Discussion index | About this forum | D home