Boost.Thread compile problems

Hi, I'm getting errors from the tss handling when compiling Boost.Thread using the DEC CXX 6.5 compiler (under OpenVMS). The compiler doesn't like the fact that a pointer to a function with C++ linkage is being passed to a function expecting a pointer to a function with "C" linkage. The function in question is when the address of "thread_specific_ptr<T>::cleanup" is used as an argument to pthread_key_create (indirectly). I'm using Boost 1.31.0. The workaround I've implemented is the following (snippets from the modified source to illustrate): --- tss.hpp --- namespace boost { namespace detail { extern "C" { typedef void (*pthread_key_destruct_cb_t)(void*); <<<=== } class BOOST_THREAD_DECL tss : private noncopyable { public: tss(pthread_key_destruct_cb_t cleanup = 0); <<<=== [snip] template <typename T> class thread_specific_ptr : private noncopyable { public: thread_specific_ptr() : m_tss(reinterpret_cast<detail::pthread_key_destruct_cb_t>(&thread_specific_p tr<T>::cleanup)) <<<=== {} [snip] --- tss.cpp --- [snip] #elif defined(BOOST_HAS_PTHREADS) tss::tss(pthread_key_destruct_cb_t cleanup) <<<=== { int res = 0; res = pthread_key_create(&m_key, cleanup); if (res != 0) throw thread_resource_error(); } [snip] ------ I'd be very grateful if you could implement something similar (this might not be the prettiest fix) before the release of 1.32.0. There are also some very annoying warnings originating from meaningless casts (from timeconv.inl), e.g.: --- timeconv.inl --- [snip] const int NANOSECONDS_PER_SECOND = 1000000000; [snip] #if defined(BOOST_HAS_PTHREADS) inline void to_timespec(const boost::xtime& xt, timespec& ts) { ts.tv_sec = static_cast<int>(xt.sec); ts.tv_nsec = static_cast<int>(xt.nsec); if(ts.tv_nsec > static_cast<const int>(NANOSECONDS_PER_SECOND)) <<<=== [snip] ------------ Basically the compiler finds it pretty meaningless to cast "const int"s to "const int"s (and so do I). Possible to fix this also? Thanks // Johan

Johan Nilsson wrote: [...]
expecting a pointer to a function with "C" linkage.
Ha! http://groups.google.com/groups?selm=3ECE1254.20134D8B%40web.de And of course <cthread> is the way to go... http://groups.google.com/groups?selm=3F7C4829.6D2E2F12%40web.de regards, alexander.

Johan Nilsson wrote:
Hi,
I'm getting errors from the tss handling when compiling Boost.Thread using the DEC CXX 6.5 compiler (under OpenVMS). The compiler doesn't like the fact that a pointer to a function with C++ linkage is being passed to a function expecting a pointer to a function with "C" linkage. The function in question is when the address of "thread_specific_ptr<T>::cleanup" is used as an argument to pthread_key_create (indirectly).
I'm using Boost 1.31.0.
[snipped suggested patch] I believe this has already been done. If you want to double-check, you can see the current version of tss.cpp here: http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/thread/src/tss.cpp?vi... and http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/thread/tss.hpp?view=... Mike

"Michael Glassford" <glassfordm@hotmail.com> wrote in message news:cf09qa$95v$1@sea.gmane.org...
Johan Nilsson wrote:
Hi,
I'm getting errors from the tss handling when compiling Boost.Thread using the DEC CXX 6.5 compiler (under OpenVMS). The compiler doesn't like the fact that a pointer to a function with C++ linkage is being passed to a function expecting a pointer to a function with "C" linkage. The function in question is when the address of "thread_specific_ptr<T>::cleanup" is used as an argument to pthread_key_create (indirectly).
I'm using Boost 1.31.0.
[snipped suggested patch]
I believe this has already been done. If you want to double-check, you can see the current version of tss.cpp here:
http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/thread/src/tss.cpp?vi...
and
http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/thread/tss.hpp?view=...
Mike
Thanks, it looks like it should be ok (can't test that version until released). However the "const int" casts are still there in timeconv.inl. // Johan

Johan Nilsson wrote: [snip]
Thanks, it looks like it should be ok (can't test that version until released). However the "const int" casts are still there in timeconv.inl.
Sorry, I missed that part of your message. I agree that the casts look unnecessary. Although I think having a warning about them is unnecessary too, I've removed the casts. Mike
participants (3)
-
Alexander Terekhov
-
Johan Nilsson
-
Michael Glassford