[MAC] 'static const std::string' in a header file

Matt Austern austern@apple.com
Sun Jan 9 09:43:00 GMT 2005


On Jan 8, 2005, at 3:42 PM, Mathieu Malaterre wrote:

> Hello,
>
>    I am working on a cross plateform DICOM lib which seems to be 
> working fairly well on a variety of plateforms except on MacOSX with 
> gcc.
>
>    If I try to run any example it gets stuck on a string construction. 
> I believe this has to do with multi thread and c++ object 
> initialization on the Mac. Could someone comment on the usage in a 
> header file of:
>
>            static const std::string foo = "bar";
>
>    Is this a bad practice ? Can it be safely replace by something else 
> that would be more 'conventional/robust' ? BTW I cannot change this to 
> a regular 'const char foo[]' since I am returning direct const 
> reference to this object.
>
> I include the gdb backtrace, hopefully this should mean something for 
> someone :)

This looks to me like a known bug in the way that file-scope objects in 
dylibs get initialized.  It will be fixed in Tiger.

			--Matt



More information about the Gcc mailing list