Boost logo

Boost :

Subject: Re: [boost] [threads] namespace & externs
From: Scot Shinderman (scot_at_[hidden])
Date: 2011-01-26 20:33:36


Anthony Williams <anthony.ajw <at> gmail.com> writes:

>
> scot shinderman <scot <at> imageworks.com> writes:
>
> > In boost/thread/src/pthread/thread.cpp we see extern "C" {}
> > around code such as tls_destructor. Is this needed so it
> > interfaces w/ native pthread local storage?
>
> Yes.
>
> > When a vendor program is built against a specific version
> > of boost it usually becomes necessary to isolate other users
> > via a namespace. However, anything with extern "C"
> > style defeats this. Aside from explicit linking to native c
> > api's are there reasons for this; also what's considered the best
> > style to isolate different versions -- currently we modify every header
> > with a version-ed namespace wrapper.
>
> extern "C" is only used where it is necessary (at least, that is the
> intent). If you need the extern "C" stuff to be versioned then you'll
> have to rename it. Renaming the namespace seems a sensible option for
> the rest of the code.

A little confused by this last part -- if the routine tls_destructor can be
renamed something i.e. tls_destructor_v2 then why does it need to be extern "C"
at all (why wouldn't the name-mangled version work as well)? If the pthread
library cannot find something called tls_destructor what will occur? So far
in small tests we haven't seen problems; with our vendor's version of boost
however thrown into the mix something stills seems awry especially during thread
tear down...

thanks!

>
> Anthony


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk