|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-01-29 15:50:54
----- Original Message -----
From: Douglas Gregor <gregod_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, January 29, 2002 5:35 PM
Subject: Re: [boost] boost bind/functional/reference wrapper/mem_fn
> On Tuesday 29 January 2002 03:06 pm, you wrote:
> > FWIW, I've solved this 'precompiled header' problem in my own copy of
the
> > bind library by replacing the global variables with inline functions:
> > That is, I did this:
> [snip cod]e
> > But unfortunately, such a change, even it if were appropriate, would
break
> > existing code.
> > However, it might help you to get through until a definitive solution is
> > found.
> >
> > BTW, I did the same with 'ignore' in the tuples library.
>
> Here's my proposed solution: give Boost three additional macros:
>
> BOOST_NAMESPACE_VARIABLE: placed before any namespace-level variable to
give
> it the appropriate linkage.
>
> BOOST_BEGIN_NAMESPACE_VARIABLES: placed before the declaration of
> namespace-level variables
>
> BOOST_END_NAMESPACE_VARIABLES: placed after the declaration of
> namespace-level variables.
>
> For bind, we would have something like:
>
> BOOST_BEGIN_NAMESPACE_VARIABLES
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<1> _1;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<2> _2;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<3> _3;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<4> _4;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<5> _5;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<6> _6;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<7> _7;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<8> _8;
> BOOST_NAMESPACE_VARIABLE boost::_bi::arg<9> _9;
> BOOST_END_NAMESPACE_VARIABLES
>
> Then we have a user-level variable that defines the current mode we are
in:
> - standalone mode, where we can use an anonymous namespace for the
> variables and no linkage is necessary. Therefore we have the following
> defines:
> #define BOOST_BEGIN_NAMESPACE_VARIABLES namespace {
> #define BOOST_END_NAMESPACE_VARIABLES }
> #define BOOST_NAMESPACE_VARIABLE
>
> - header mode, where we declare all of these external:
> #define BOOST_BEGIN_NAMESPACE_VARIABLES
> #define BOOST_END_NAMESPACE_VARIABLES
> #define BOOST_NAMESPACE_VARIABLE extern
>
> - object file mode, where we declare the actual instances
> #define BOOST_BEGIN_NAMESPACE_VARIABLES
> #define BOOST_END_NAMESPACE_VARIABLES
> #define BOOST_NAMESPACE_VARIABLE
>
> Finally, we provide a "variable definitions" file that #includes all of
the
> headers in Boost using the object file mode. The user can then use header
> mode for their program, and add the variable definitions file to their
> project/makefile to get the required definitions.
>
> Doug
>
In the overall, this look good to me. I think the configuration you propose
would work.
But I would provide a per-library variable definition file, not a single
file for the whole boost.
That is, the bind library, for instance, could come with:
bind_globals.hpp
~~~~~~~~~~~
BOOST_BEGIN_NAMESPACE_VARIABLES
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<1> _1;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<2> _2;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<3> _3;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<4> _4;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<5> _5;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<6> _6;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<7> _7;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<8> _8;
BOOST_NAMESPACE_VARIABLE boost::_bi::arg<9> _9;
BOOST_END_NAMESPACE_VARIABLES
The user would normally include "bind.hpp" with either standalone or header
mode selected.
"bind.hpp" would include "bind_globals.hpp".
If header mode was used, he would additionaly include "bind_globals.hpp" in
a source file with object file mode selected.
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk