|
Boost : |
Subject: [boost] Compilation error in boost::bind
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-06-17 14:27:23
The documentation for __stdcall in MSVC says the following:
On Itanium Processor Family (IPF) and x64 processors, __stdcall is
accepted and ignored by the compiler.
Because of this, the following fragment from <boost/bind/bind.hpp>
fails when causes build errors for either of these platforms:
#define BOOST_BIND_CC
#define BOOST_BIND_ST
#include <boost/bind/bind_cc.hpp>
#undef BOOST_BIND_CC
#undef BOOST_BIND_ST
#ifdef BOOST_BIND_ENABLE_STDCALL
#define BOOST_BIND_CC __stdcall
#define BOOST_BIND_ST
#include <boost/bind/bind_cc.hpp>
#undef BOOST_BIND_CC
#undef BOOST_BIND_ST
#endif
Since it ignores the __stdcall the second time around, all the
templates are re-declared with cdecl causing duplicate symbol
definition errors. This is confirmed on MSVC 9.0 but I assume it
exists on all versions of MSVC.
What is the best way to fix this? I don't know much about how to use
the BOOST_WORKAROUND macros, but I have patched this in my own version
of bind.hpp by changing the block inside the ifdef to the following:
#if defined(BOOST_BIND_ENABLE_STDCALL) && !(defined(BOOST_MSVC) &&
defined(_WIN64))
#define BOOST_BIND_CC __stdcall
#define BOOST_BIND_ST
#include <boost/bind/bind_cc.hpp>
#undef BOOST_BIND_CC
#undef BOOST_BIND_ST
#endif
This doesn't handle the itanium case obviously but off the top of my
head I'm not sure what MSVC #defines for itanium.
What would be the most robust way to fix this?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk