> -----Original Message-----
> From: Martin Sebor [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 28, 2007 10:29 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [PATCH] STDCXX-77
> 
> Farid Zaripov wrote:
> >> -----Original Message-----
> >> From: Martin Sebor [mailto:[EMAIL PROTECTED] On Behalf Of Martin 
> >> Sebor
> >> Sent: Tuesday, August 28, 2007 7:11 PM
> >> To: stdcxx-dev@incubator.apache.org
> >> Subject: Re: [PATCH] STDCXX-77
> >>
> >> I have one concern with the introduction of dynamic initialization 
> >> and the pragma into the library. First, our
> >> (undocumented) design goal is to avoid requiring dynamic 
> >> initialization in the library.
> >> I.e., there should be no code in the library that runs at startup.
> >> The rationale for it is efficiency and avoiding user code 
> issues due 
> >> to initialization dependencies. Since other libraries may use the 
> >> same pragma, they will be subject to initialization 
> dependencies that 
> >> we try to avoid.
> >>
> >> Unless there is a way to avoid the dynamic initialization 
> or defer it 
> >> until runtime (i.e., initialize the handler lazily)
> > 
> >   We need initialize the handler before first operator 
> new() call (or 
> > from first oprator new() call), but I have not see the possible way 
> > for this.
> 
> I wonder if defining DllMain() and setting the handler there, 
> for DLLs only, would deal with the initialization dependency 
> issue, albeit at the cost of a (small) runtime hit.

  Setting handler from DllMain() is the same as the solution, provided
in my patch,
because of global objects are constructed from DllMain() (exactly
function name
is DllMainCRTStartup()). The #pragma init_seg(dll) only tells, that
objects in
current .cpp file will be constructed before objects from modules with
#pragma init_seg(user), and ordinary global objects (but after the
objects
from modules with #pragma init_seg(compiler)). The MSVC initializes CRT
global
objects using #pragma init_seg(compiler).

Farid.

Reply via email to