Operaror 'new' inside WinMain crashes at runtime
Sean Kelly
sean at f4.ca
Thu Aug 10 07:50:14 PDT 2006
Serg Kovrov wrote:
> * Derek Parnell:
>> Confirmed. However this is not the way to write Windows apps. You missed
>> out all the GC stuff. The code should look like this ...
>
> Thanks for pointing that, Derek. It is silly of me that I forgot about
> that =)
>
> But isn't it tedious to type/copy this for every new windows program one
> start to write?
>
> And appears to me, this is some inner GC stuff that might me changed at
> some point. If so, maybe this should not be used directly by application
> programmer? I believe it is better to have compiler/standard library to
> do it instead. Just like it does for main() function.
>
> Even better, if application programmer do always write main(), but if in
> .def there is 'SUBSYSTEM WINDOWS' string, compiler/standard library
> substitutes it with proper entry point with proper inners stuff
> initialization.
>
> Or even better than better, is to omit .def files and have some pragmas
> in source file instead? Resulting programs could be more
> portable/deployable then...
What I did for a while was to call C main from WinMain, as that's where
the D startup code lives. However, someone told me that it's possible
to have C main as the entry point for a Win app so I got rid of the
module that I used to use. I don't suppose anyone can confirm this or
say how to do it? It seems it would be far cleaner than linking against
a WinMain module manually, even if the administrative bits are
abstracted out.
Sean
More information about the Digitalmars-d-bugs
mailing list