Subj : Re: How to pass class-member function to pthread_create(....)? To : comp.programming.threads From : Torsten Robitzki Date : Mon Jul 18 2005 11:04 pm Vyacheslav Kononenko wrote: > > Torsten Robitzki wrote: > >>Vyacheslav Kononenko wrote: >> >> >>>Chris Thomasson wrote: >>> >>> >>>>>>Unfortunately extern "C" is necessary if your interested in creating >>>>>>"correct code"... >>>>> >>>>>The problem is using extern "C" does _NOT_ make 100% correct code >>>>>either. It could be safer to do that. But could be safer is different >>>>>than correct/incorrect statements showed here. >>>> >>>>I would argue that it is "correct" to use extern "C" for the functions you >>>>pass to a pthreads library; pthreads is a C library after all... >>> >>> >>>extern "C" does not gurantee that your C++ function would be correctly >>>callable from any C code. >> >>So what's the point of declaring a function extern "C" other then make >>it callable from C? > > But make it callable from C is different than guarantee that _ANY_ C > code compiled by _ANY_ C compiler or C++ compiler in C mode with _ANY_ > set of options will call extern "C" function correctly, isn't it? One can't make it callable from every C compiler, but from every sane C compiler on your platform. Extern "C" is a feature of your C++ compiler and if that compiler don't behave like it it's requested by your platform ABI it's prety pointless. >>It might work. But why would one gamble and depend on something that >>might work if there is an easy approach that is required to work because >>there are specifications that guaranties that this approach will work? > > > There is no such specifications that the problem. You have to know that > your C library compiler code is compatible with C++ compiler generated > code anyway. And you can know if it is safe to call extern "C++" > linkage from the C library as well. I would expect a compiler that can't generate code with the requested linkage to issue an error. regards Torsten .