www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - WinMain or main

reply Samuel <Samuel_member pathlink.com> writes:
Windows applications in dmd's sample directory all define a "WinMain" as the
entry point, but I notice that DWT's GUI samples all use the good old "main"
function, and the compiled programs still start normally without displaying a
console window. I'm a bit confused. Shouldn't all Win32 GUI programs provide a
WinMain? Why does "main" work, too?
Sep 10 2005
next sibling parent J Thomas <jtd514 ameritech.net> writes:
Its been a few years since I've read Windows Internals, but if I recall 
correctly, all exes have a main(). windows GUI apps are built with a 
default runtime main() that calls WinMain(). therefore its possible to 
build a windows gui app with a main() entry point.

as I said its been many years since ive researched this and vaguely 
remember the details, but I think its something like this....


Samuel wrote:
 Windows applications in dmd's sample directory all define a "WinMain" as the
 entry point, but I notice that DWT's GUI samples all use the good old "main"
 function, and the compiled programs still start normally without displaying a
 console window. I'm a bit confused. Shouldn't all Win32 GUI programs provide a
 WinMain? Why does "main" work, too?
 
 
Sep 11 2005
prev sibling parent reply J Thomas <jtd514 ameritech.net> writes:
also note, its possible to create a win32 console app that creates a 
gui, which is another reason those samples may be using a main()


Samuel wrote:
 Windows applications in dmd's sample directory all define a "WinMain" as the
 entry point, but I notice that DWT's GUI samples all use the good old "main"
 function, and the compiled programs still start normally without displaying a
 console window. I'm a bit confused. Shouldn't all Win32 GUI programs provide a
 WinMain? Why does "main" work, too?
 
 
Sep 11 2005
parent reply Hasan Aljudy <hasan.aljudy gmail.com> writes:
I noticed glut does that.

This maybe OT, but can you compile code which uses main() so that it 
doesn't show a black console window when it runs?

J Thomas wrote:
 also note, its possible to create a win32 console app that creates a 
 gui, which is another reason those samples may be using a main()
 
 
 Samuel wrote:
 
 Windows applications in dmd's sample directory all define a "WinMain" 
 as the
 entry point, but I notice that DWT's GUI samples all use the good old 
 "main"
 function, and the compiled programs still start normally without 
 displaying a
 console window. I'm a bit confused. Shouldn't all Win32 GUI programs 
 provide a
 WinMain? Why does "main" work, too?
Sep 11 2005
next sibling parent John Reimer <terminal.node gmail.com> writes:
Hasan Aljudy wrote:
 I noticed glut does that.
 
 This maybe OT, but can you compile code which uses main() so that it 
 doesn't show a black console window when it runs?
 
 J Thomas wrote:
All these questions have been asked before (several times over). You might like to searth this and the old D newsgroup for the solutions. Also have a look at the C++ newsgroup too since these questions are not D language specific ones. D wiki site is another good resource. It shows how to eliminate the black console. -JJR
Sep 11 2005
prev sibling parent Bruno Medeiros <daiphoenixNO SPAMlycos.com> writes:
Hasan Aljudy wrote:
 I noticed glut does that.
 
 This maybe OT, but can you compile code which uses main() so that it 
 doesn't show a black console window when it runs?
 
Yes you can, you can use main() and choose whether or not the console appears, it depends only on some compiler options. I've done that (with an SDL app) in both VC++, MinGW, and DMD (ported to D). Cant explain exactly why (not that it matters much) since I don't know the internal details myself (altough I'd like to). -- Bruno Medeiros Computer Science/Engineering student
Sep 12 2005