Operaror 'new' inside WinMain crashes at runtime

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Fri Aug 11 12:35:46 PDT 2006


Sean Kelly wrote:
> 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

Yes, just link a C main program with a def file with:
   EXETYPE NT
   SUBSYSTEM WINDOWS
and a program without the console window will be created. That's what 
the dbuild option "-gui" does as well. (now that I think about it, that 
option seems a bit misnamed, maybe it should be "-win"? :) )

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d-bugs mailing list