Boost logo

Boost Users :

From: Johan Nilsson (johan.nilsson_at_[hidden])
Date: 2003-08-21 06:29:17


Hi,

I've just tried to compile boost.thread under OpenVMS and got it working
mostly fine, with a few quirks. I'm using Boost 1.30.2 and DEC C++ 6.5 under
OpenVMS Alpha 7.1-1H1. OpenVMS provides a compliant(?) pthreads
implementation. Note that I did _not_ use Boost.jam (I did try, but couldn't
get it going).

Compiling the .cpp files under BOOST_ROOT/libs/thread/src works pretty fine,
once having defined BOOST_HAS_THREADS, BOOST_HAS_PTHREADS and
BOOST_HASTIMEOFDAY on the compiler's commandline. But not for tss.cpp - I
get the following error:

-------------------------------------------------------------------------
    res = pthread_key_create(&m_key, cleanup);
.....................................^
%CXX-E-INCOMPATIBLEPRM, argument of type "void (*)(void *)" is incompatible
          with parameter of type "void (*)(void *) C"
at line number 192 in file
DISK$USER1:[COMMON.BOOST.LIBS.THREAD.SRC]TSS.CPP;1
----------------------------------------------------------------------------

---
After some digging around I found out that the error only appears when using
the compiler switch "/standard=strict_ansi", which is what I'm using all the
time. Now to me it looks like the DEC C++ compiler believes that name
mangling isn't the only thing that differs between "C" and "C++" linkage -
does anyone here have any comments on that? See below for a small example
(and possible way to work around this in the boost.thread implementation):
------ sample.cpp -------
extern "C" {
typedef void (*c_linkage_cb_t)(void*);
void c_linkage(void (*pfn)(void*));
}
inline
void
cpp_linkage_using_c_typedef(c_linkage_cb_t pfn)
{
 c_linkage(pfn);
}
inline
void
cpp_linkage(void (*pfn)(void*))
{
 c_linkage(pfn);
}
---------------- end sample.cpp -------------------
And here's the output from the compiler:
$ cxx /standard=strict_ansi t.cpp
        c_linkage(pfn);
..................^
%CXX-E-INCOMPATIBLEPRM, argument of type "void (*)(void *)" is incompatible
          with parameter of type "void (*)(void *) C"
at line number 19 in file DISK$USER1:[COMMON.BOOST.LIBS.THREAD.SRC]T.CPP;11
I don't know if this is a compiler bug or not, but in order to work around
this in boost.thread, wouldn't it be feasible to provide a similar fix to
the tss implementation to avoid the compilation problem - e.g.
---- tss.hpp -----
...
extern "C" {
typedef int (*pthread_<something>_cb_t)(void*);
}
...
class tss { ...
...
tss(pthread_<something>_cb_t cb)
...
--- end tss.hpp ----
Comments appreciated
// Johan

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net