Subj : Re: How to pass class-member function to pthread_create(....)? To : comp.programming.threads From : Jedrzej Dudkiewicz Date : Tue Jul 19 2005 05:17 pm > > We use C headers and C libraries in C++ code. The only way to achieve it in > > C++ is to declare function passed to this libraries as extern "C". > > Thats simply not true. It is NOT the ONLY way, sorry. Just a sample > from C++ standard (§25.4): > > extern "C" void qsort(void* base, size_t nmemb, size_t size, > int (*compar)(const void*, const void*)); > > extern "C++" void qsort(void* base, size_t nmemb, size_t size, > int (*compar)(const void*, const void*)); > > Another solution could be to make pthread_create not extern "C" in > header (just default) and provide two version of it in the library - > one for C and one for C++. And thats need to be done only in compiler > where C++ and C functions use different calling conventions. Now, I don't know what you want. You said: > I am sorry, but I would like to see what POSIX says about C linkage in > pthread_create, not your comments on that. Can you make a quote? Standard says: Function prototypes must be provided for use with an ISO C compiler. I assume, that if interface (function prototypes) is in C, passed data MUST be C-compatible. Library can be implemented in java or python, but it must provide C interface. You also wrote: > You have to know that > your C library compiler code is compatible with C++ compiler generated > code anyway. No. Your C++ compiler must be compatible with C library compiler. Not the other way around. > And you can know if it is safe to call extern "C++" > linkage from the C library as well. Maybe, but it's not required by any standard, so you can't count on it. JD .