Subj : Re: How to pass class-member function to pthread_create(....)? To : comp.programming.threads From : Vyacheslav Kononenko Date : Tue Jul 19 2005 11:02 am Jedrzej Dudkiewicz wrote: > > > 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 (=A725.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. That does not mean that C++ must use what is provided for ISO C compiler, does it? > I assume, that if interface (function prototypes) is in C, passed data MU= ST > be C-compatible. Library can be implemented in java or python, but it must > provide C interface. I am sorry, but what I got in this group some facts from standards and many assumtions to link that facts together and then conclusion that is only right opinion and anything different is false. What if somebody does not share your assumtion? > 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 What is required by a standard and which one, what I can count on? Regards, Vyacheslav .