What runs before main()?

Posted by MikimotoH on Stack Overflow See other posts from Stack Overflow or by MikimotoH
Published on 2011-01-10T23:51:33Z Indexed on 2011/01/10 23:53 UTC
Read the original article Hit count: 127

Filed under:

After testing on msvc8, I found:

  1. Parse GetCommandLine() to argc and argv
  2. Standard C Library initialization
  3. C++ Constructor of global variables

These three things are called before entering main().

My questions are:

  1. Will this execution order be different when I porting my program to different compiler (gcc or armcc), or different platform?
  2. What stuff does Standard C Library initialization do? So far I know setlocale() is a must.
  3. Is it safe to call standard C functions inside C++ constructor of global variables?

© Stack Overflow or respective owner

Related posts about c++