Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-06-21 21:59:58


From: Lois Goldthwaite <loisg_at_[hidden]>
> Bill Kempf wrote:
> >>static thread * create(void (*threadfunc)(void*), void* param);
> Greg Colvin wrote:
> > Is the ugly (void (*threadfunc)(void*), void* param) really needed?
>
> I haven't dug into your code, but let us not forget that any function
> used to create a thread must have extern "C" linkage. A class member
> function, even a static one, won't do. FYI, the Objectspace threads
> library uses an internal driver function with "C" linkage, taking a
> single void * parameter, which points to a structure containing the real
> thread_func and param pointers. So when the thread starts running the
> driver function, the first thing it does is invoke threadfunc(param).

The usual trick is to wrap an "extern C" trampoline around the
C++ function or function object.


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