Re: global and static object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



George wrote:
Thanks Ben,


Initialization of globals is done by the CRT, because C programs can
use this. C++ global constructors are placed in the same list of
global initialization, so the CRT runs those without knowing whether
it is construction of a C++ object or initialization of a C variable.

You mean CRT just treat constructor invocation as a part of
initialization code to execute before executing main, and CRT has no
need to distinguish or identify what is doing in the initialization
(constructor invocation)?

Yes. The compiler create function pointers to all the initialization
functions, the linker places them into a special section, the CRT runs
through the whole list and executes the functions. It doesn't need to know
whether those functions call C++ constructors or not.



regards,
George


.



Relevant Pages

  • Re: global and static object
    ... C++ global constructors are placed in the same list of global ... construction of a C++ object or initialization of a C variable. ... You mean CRT just treat constructor invocation as a part of initialization ...
    (microsoft.public.vc.language)
  • Re: C++ Runtime Binding
    ... What you're saying is that when the CRT is linked, ... that calls the constructors and destructors of global/static objects. ... Notice Igor carefully referred to global/static objects' constructors/ ...
    (microsoft.public.vc.atl)
  • Initialization of virtual function table pointer
    ... examining the assembly code associated with constructors I noticed that the ... dynamic-dispatch mechanism was enabled before member initialization but after ... indirectly calling a virtual function. ...
    (comp.lang.cpp)
  • Mixed-Mode Assembly CRT Initialization Question
    ... application to functionality resident in a C++ static lib. ... I believe the problem may be due to the absence of initialized CRT when the ... C++ library statics are being initialized. ... I need to call the CRT initialization exports early enough such that the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: C++ Runtime Binding
    ... > that calls the constructors and destructors of global/static objects. ... calls to constructors and destructors are emitted at compile time ... The start-up code (be it in CRT or ATL7) simply ...
    (microsoft.public.vc.atl)