Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2004-02-18 06:23:04


[Problem with <bind.hpp> and <function.h> on BCC 6.4]

I found what;s the cause: <boost/mem_fn.hpp> is included
by <function.hpp> and so if one writes:

----------------
#include <boost/function.hpp>
#define BOOST_MEM_FN_ENABLE_FASTCALL
#include <boost/bind.hpp>
----------------

it results with Bind using differently pre-processed <mem_fn.hpp>
than it is expected.

Bellow is solution to produce clean error message
when this situation happens:

------- file boost/mem_fn.hpp --------------
1. remove #pragma once

2. on its place put following text:

// Since this header is included by <function.hpp>: if you define
// any of following tags after that and then include <bind.hpp>,
// compilation will fail with hard to understand message.
//
// The macros bellow are in order to give early and understandable
// failure during precompilation.
#ifdef BOOST_BIND_ENABLE_STDCALL
# define BOOST_BIND_ENABLE_STDCALL_TAG
#endif
#ifdef BOOST_BIND_ENABLE_FASTCALL
# define BOOST_BIND_ENABLE_FASTCALL_TAG
#endif
#ifdef BOOST_BIND_ENABLE_PASCA
# define BOOST_BIND_ENABLE_PASCAL_TAG
#endif

3. at the end of mem_fn.hpp put:

...
#else
// Check for multiple include with different calling conventions enabled.
// See top of header for more details.
#ifdef BOOST_BIND_ENABLE_STDCALL
# ifndef BOOST_BIND_ENABLE_STDCALL_TAG
# error <function.hpp> or other header using <mem_fn.hpp> was included
before <bind.hpp>. Please include <bind.hpp> first.
# endif
#endif
#ifdef BOOST_BIND_ENABLE_FASTCALL
# ifndef BOOST_BIND_ENABLE_FASTCALL_TAG
# error <function.hpp> or other header using <mem_fn.hpp> was included
before <bind.hpp>. Please include <bind.hpp> first.
# endif
#endif
#ifdef BOOST_BIND_ENABLE_PASCAL
# ifndef BOOST_BIND_ENABLE_PASCAL_TAG
# error <function.hpp> or other header using <mem_fn.hpp> was included
before <bind.hpp>. Please include <bind.hpp> first.
# endif
#endif

#endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED

------------------------------------

/Pavel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk