🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Claus A. Faerber Wed, 07 Feb 1996 20:31
Re: Are all Windows programs ill-formed?
#3324
Author: Claus A. Faerber
Date: Wed, 07 Feb 1996 20:31
31 lines
2083 bytes
David Byrden <100101.2547@compuserve.com> (02 Feb 96):

> >> It requires every program to have the main() function (which
> >> implementation is not allowed to supply) with parameters (void) or (int
> >> argc, int*argv[]). However, Windows programs have another convention:
> >> prrogram must contain the function  int WinMain
>
> I remember reading that you can write a Windows program with a main()
> function and the usual command line arguments, and then the Microsoft
> compiler will then generate WinMain somehow....but that the "operating
> system" does link to WinMain.

No, the operating system doesn't care whether there is a  
WinMain(), a main() or anything else. It just reads a  
pointer  from the exe file and calls it. This is usually the  
C/C++ statup code, which then calls WinMain() or main().
If there is a main present, the linker makes the startup  
code call it, if not the linker either sets in an own  
main(), which calls WinMain(), or another startup code,  
which calls main().

Claus

------------------------------------------------------------------------
Claus Andre Faerber - claus@faerber.muc.de - http://www.muc.de/~cfaerber
------------------------------------------------------------------------

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
]
Re: Are all Windows programs ill-formed?
#3373
Author: Max TenEyck Woodbury
Date: Tue, 20 Feb 1996 18:50
25 lines
2019 bytes
The requirement for a 'main' can NOT be built into the compiler because
a program can be split into seperatly compilable source modules.  When
compiling any given module there is no way of determining if it is the
one and only module in the program that contains 'main'.  At best the
requirement for a 'main' is a requirement on the linker.

Actually requiring a program to have a 'main' may be a problem.  What
should probably be required is a capability to have a 'main' but allow
other mechanisms that produce a comparable effect.  (No, I have no idea
how to phrase that.)

There are other extensions to be considered.  A number of UNIX based
systems allow an 'envp' as a third argument.  This seems to imply that
'main' is quite different from other C++ functions that overload on the
number and type of its arguments.  In fact, it is much closer to a 'C'
style function in its ability to handle a variable number of arguments.

        Max
---
[ To submit articles: Try just posting with your newsreader.  If that fails,
                      use mailto:std-c++@ncar.ucar.edu
  FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  Comments? mailto:std.c++-request@ncar.ucar.edu 
]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads