Connecting Tech Pros Worldwide Help | Site Map

What happens before main()?

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 7th, 2006, 01:45 AM
Tony
Guest
 
Posts: n/a
Default What happens before main()?

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




  #2  
Old December 7th, 2006, 02:05 AM
Noah Roberts
Guest
 
Posts: n/a
Default 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.

  #3  
Old December 7th, 2006, 02:15 AM
Victor Bazarov
Guest
 
Posts: n/a
Default 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


  #4  
Old December 7th, 2006, 12:05 PM
Pete Becker
Guest
 
Posts: n/a
Default 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)
  #5  
Old December 7th, 2006, 02:35 PM
Noah Roberts
Guest
 
Posts: n/a
Default 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?

  #6  
Old December 7th, 2006, 09:15 PM
Tony
Guest
 
Posts: n/a
Default 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


  #7  
Old December 7th, 2006, 11:45 PM
Gavin Deane
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.