Subj : Re: How to pass class-member function to pthread_create(....)? To : comp.programming.threads From : Vyacheslav Kononenko Date : Mon Jul 18 2005 01:50 pm 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? > 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. > > regards > Torsten Regards, Vyacheslav .