Jump to page: 1 2
Thread overview
make D windows-aware
Mar 22, 2006
Sean Kelly
Mar 23, 2006
Chris Miller
Mar 23, 2006
Regan Heath
Mar 23, 2006
kris
Mar 23, 2006
Hasan Aljudy
Mar 23, 2006
Regan Heath
Mar 23, 2006
Sean Kelly
Mar 22, 2006
Chris Miller
March 22, 2006
DMD is Windows-aware in the sense that if you have a WinMain(), it emits a reference to acrtused or whatever, but what I mean is make it so we don't have to manually put all the D init / deinit code in the WinMain().  I mean, when we define main() for a console program, it automatically calls dmain() which calls main().  Why not make it so when we define WinMain(), it automatically calls DWinMain() before our WinMain() or something?

I can only see this as an advantage, as well, as then any fancy things Walter puts into dmain (like exception stack traces and just exception handling in general) will be put into DWinMain as well, instead of the "WinMain" living in (of all places) the docs and having to be copied into any Windows programs.


March 22, 2006
Jarrett Billingsley wrote:
> DMD is Windows-aware in the sense that if you have a WinMain(), it emits a reference to acrtused or whatever, but what I mean is make it so we don't have to manually put all the D init / deinit code in the WinMain().  I mean, when we define main() for a console program, it automatically calls dmain() which calls main().  Why not make it so when we define WinMain(), it automatically calls DWinMain() before our WinMain() or something?

This thread seems pertinent:

http://www.digitalmars.com/d/archives/digitalmars/D/learn/1815.html

Sean
March 22, 2006
On Wed, 22 Mar 2006 14:30:29 -0500, Jarrett Billingsley <kb3ctd2@yahoo.com> wrote:

> DMD is Windows-aware in the sense that if you have a WinMain(), it emits a
> reference to acrtused or whatever, but what I mean is make it so we don't
> have to manually put all the D init / deinit code in the WinMain().  I mean,
> when we define main() for a console program, it automatically calls dmain()
> which calls main().  Why not make it so when we define WinMain(), it
> automatically calls DWinMain() before our WinMain() or something?
>
> I can only see this as an advantage, as well, as then any fancy things
> Walter puts into dmain (like exception stack traces and just exception
> handling in general) will be put into DWinMain as well, instead of the
> "WinMain" living in (of all places) the docs and having to be copied into
> any Windows programs.
>

I just always use a D main and tell the linker what type of exe to make (pass -L/exet:nt/su:windows:4.0 or similar to DMD). I think this is how it always should have been. This lets you use D main char[][]args and/or WinMain args via GetCommandLine().
March 23, 2006
"Sean Kelly" <sean@f4.ca> wrote in message news:dvsgih$1rhe$1@digitaldaemon.com...
> This thread seems pertinent:
>
> http://www.digitalmars.com/d/archives/digitalmars/D/learn/1815.html
>
> Sean

I'll try that, though it makes it a bit awkward to get the hInstance parameter which I need.


March 23, 2006
On Wed, 22 Mar 2006 19:34:19 -0500, Jarrett Billingsley <kb3ctd2@yahoo.com> wrote:

> "Sean Kelly" <sean@f4.ca> wrote in message
> news:dvsgih$1rhe$1@digitaldaemon.com...
>> This thread seems pertinent:
>>
>> http://www.digitalmars.com/d/archives/digitalmars/D/learn/1815.html
>>
>> Sean
>
> I'll try that, though it makes it a bit awkward to get the hInstance
> parameter which I need.
>

Can just use GetModuleHandleA(null)
March 23, 2006
"Chris Miller" <chris@dprogramming.com> wrote in message news:op.s6uctr1mpo9bzi@moe...
> Can just use GetModuleHandleA(null)

Why thank you.  I was wondering if there was an API call to get that.

Now the only problem is that exceptions are displayed on the command line instead of popping up.. which may be a problem for the other programmers in my little group..


March 23, 2006
On Wed, 22 Mar 2006 20:27:04 -0500, Jarrett Billingsley <kb3ctd2@yahoo.com> wrote:
> "Chris Miller" <chris@dprogramming.com> wrote in message
> news:op.s6uctr1mpo9bzi@moe...
>> Can just use GetModuleHandleA(null)
>
> Why thank you.  I was wondering if there was an API call to get that.
>
> Now the only problem is that exceptions are displayed on the command line
> instead of popping up.. which may be a problem for the other programmers in
> my little group..

Can you catch them all in WinMain i.e.

try {
  ..main..
} catch(Object o) {
  MessageBox(...
}

Regan
March 23, 2006
"Regan Heath" <regan@netwin.co.nz> wrote in message news:ops6uelhqc23k2f5@nrage.netwin.co.nz...
> Can you catch them all in WinMain i.e.
>
> try {
>   ..main..
> } catch(Object o) {
>   MessageBox(...
> }

If I use the method proposed by Sean, I'd have to catch the exceptions in my own main function, as the dmain catches them and prints them to the console. i.e.

extern(C) main(..)

int WinMain(..)
{
    return main(1, &cmdline);
}

void main()
{
    try
    {
        crap
    }
    catch(Exception e)
    {
        MessageBox("oh man" ~ e.toString());
    }
}

Pretty ugly.


March 23, 2006
Jarrett Billingsley wrote:
> "Regan Heath" <regan@netwin.co.nz> wrote in message news:ops6uelhqc23k2f5@nrage.netwin.co.nz...
> 
>>Can you catch them all in WinMain i.e.
>>
>>try {
>>  ..main..
>>} catch(Object o) {
>>  MessageBox(...
>>}
> 
> 
> If I use the method proposed by Sean, I'd have to catch the exceptions in my own main function, as the dmain catches them and prints them to the console. i.e.
> 
> extern(C) main(..)
> 
> int WinMain(..)
> {
>     return main(1, &cmdline);
> }
> 
> void main()
> {
>     try
>     {
>         crap
>     }
>     catch(Exception e)
>     {
>         MessageBox("oh man" ~ e.toString());
>     }
> }
> 
> Pretty ugly. 

You might ask Sean to decouple the default exception-handler from the runtime support in Ares. The idea would be that you could provide your own default-handler, and then the linker would bind that instead. Sean is already doing a lot of things like that with Ares, so it may not be too much of a stretch.
March 23, 2006
Jarrett Billingsley wrote:
> "Regan Heath" <regan@netwin.co.nz> wrote in message news:ops6uelhqc23k2f5@nrage.netwin.co.nz...
> 
>>Can you catch them all in WinMain i.e.
>>
>>try {
>>  ..main..
>>} catch(Object o) {
>>  MessageBox(...
>>}
> 
> 
> If I use the method proposed by Sean, I'd have to catch the exceptions in my own main function, as the dmain catches them and prints them to the console. i.e.
> 
> extern(C) main(..)
> 
> int WinMain(..)
> {
>     return main(1, &cmdline);
> }
> 
> void main()
> {
>     try
>     {
>         crap
>     }
>     catch(Exception e)
>     {
>         MessageBox("oh man" ~ e.toString());
>     }
> }
> 
> Pretty ugly. 
> 
> 

I think you can use the new scope(failure) construct!
« First   ‹ Prev
1 2