Reasonable static initialization assurance

corey taylor corey.taylor@gmail.com
Mon Sep 19 14:27:00 GMT 2005


Yea, I figured as much.  

Current solution uses a character array for the global variable and a
static accssor that assigns that to a static const std::string.

I knew there was no way around that -- but I thought there might be
some way to do it, in some order.

Eljay,

  Do you know of any difference in this area with the OSX gcc?

corey

On 9/19/05, John Love-Jensen <eljay@adobe.com> wrote:
> Hi Corey,
> 
> > Is there any way to ensure a static variable in file.b is initialized before
> being used?
> 
> Yes, but you'll have to refactor your code a bit.
> 
> Use a static function in FileB to return FileB's static data (which is
> static data inside that static function).
> 
> Have FileA get to the FileB's static data through that accessor function.
> 
> HTH,
> --Eljay
> 
>



More information about the Gcc-help mailing list