|
Boost : |
From: Johan Nilsson (johan.nilsson_at_[hidden])
Date: 2004-08-06 07:46:26
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk