Connecting Tech Pros Worldwide Forums | Help | Site Map

What happens before main()?

Tony
Guest
 
Posts: n/a
#1: Dec 7 '06
What happens before main()?

Perhaps someone can explain it succintly and perhaps
someone has a link where it is described? crt0.lib or
something like that comes to mind (surely I have the
source code to that given that I have a number of
compilers (some very old) but I'd rather get some
rough idea first of what's happening there). Is it just
setting up an environment in which the C++ library
will work? What happens from the time a program
is started (typing the name on the command line and
pressing enter, for example) until it starts initializing
application program objects and then ending up at main()?

Tony




Noah Roberts
Guest
 
Posts: n/a
#2: Dec 7 '06

re: What happens before main()?



Tony wrote:
Quote:
What happens before main()?
>
Perhaps someone can explain it succintly and perhaps
someone has a link where it is described? crt0.lib or
something like that comes to mind (surely I have the
source code to that given that I have a number of
compilers (some very old) but I'd rather get some
rough idea first of what's happening there). Is it just
setting up an environment in which the C++ library
will work? What happens from the time a program
is started (typing the name on the command line and
pressing enter, for example) until it starts initializing
application program objects and then ending up at main()?
It's implementation defined.

Victor Bazarov
Guest
 
Posts: n/a
#3: Dec 7 '06

re: What happens before main()?


Tony wrote:
Quote:
What happens before main()?
Construction of static objects defined at the namespace
level happens. Everything else is implementation-defined.
Quote:
Perhaps someone can explain it succintly and perhaps
someone has a link where it is described?
Perhaps.
Quote:
crt0.lib or
something like that comes to mind (surely I have the
source code to that given that I have a number of
compilers (some very old) but I'd rather get some
rough idea first of what's happening there). Is it just
setting up an environment in which the C++ library
will work?
Yes. Probably. In your system, that is.
Quote:
What happens from the time a program
is started (typing the name on the command line and
pressing enter, for example) until it starts initializing
application program objects and then ending up at main()?
That's up to the hosting environment and beyond the scope
of this newsgroup.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Pete Becker
Guest
 
Posts: n/a
#4: Dec 7 '06

re: What happens before main()?


Noah Roberts wrote:
Quote:
Tony wrote:
Quote:
>What happens before main()?
>>
>Perhaps someone can explain it succintly and perhaps
>someone has a link where it is described? crt0.lib or
>something like that comes to mind (surely I have the
>source code to that given that I have a number of
>compilers (some very old) but I'd rather get some
>rough idea first of what's happening there). Is it just
>setting up an environment in which the C++ library
>will work? What happens from the time a program
>is started (typing the name on the command line and
>pressing enter, for example) until it starts initializing
>application program objects and then ending up at main()?
>
It's implementation defined.
>
Implementation-specific, but not implementation-defined. The latter is a
technical term in the C++ standard. It requires that the implementation
document its behavior.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Noah Roberts
Guest
 
Posts: n/a
#5: Dec 7 '06

re: What happens before main()?



Victor Bazarov wrote:
Quote:
Tony wrote:
Quote:
What happens before main()?
>
Construction of static objects defined at the namespace
level happens.
What about static objects at the class level? Is that different?

Tony
Guest
 
Posts: n/a
#6: Dec 7 '06

re: What happens before main()?



"Victor Bazarov" <v.Abazarov@comAcast.netwrote in message
news:FIKdncXpibc8EerYnZ2dnUVZ_rWdnZ2d@comcast.com. ..
Quote:
Tony wrote:
Quote:
>What happens before main()?
>
Construction of static objects defined at the namespace
level happens. Everything else is implementation-defined.
Sounds like something I may be hacking on at some time.
Maybe all that is necessary is the static initialization and
main() is too specialized for a specific paradigm (the UNIX
filter type of program).

Tony


Gavin Deane
Guest
 
Posts: n/a
#7: Dec 8 '06

re: What happens before main()?



Noah Roberts wrote:
Quote:
Victor Bazarov wrote:
Quote:
Tony wrote:
Quote:
What happens before main()?
Construction of static objects defined at the namespace
level happens.
>
What about static objects at the class level? Is that different?
The definition of a class's static data member has to appear at
namespace scope so Victor's statement implicitly includes static data
members.

Gavin Deane

Closed Thread