|
Boost : |
Subject: Re: [boost] [Booster] Or boost is useless for library developers
From: Artyom (artyomtnk_at_[hidden])
Date: 2010-05-16 03:19:50
>
> Now this is an interesting issue. We stumbled over the same
> issue when
> discussing how to best integrate boost in CLucene ([1]). I
> think boost
> could use a user-controlled name mangling facility so a
> binary library
> distributor could make sure the symbols from the boost he
> ships do not
> collide with boost symbols in other code.
There are few ways to do it.
If you have header-only library you may compile all your source code
with visibility=hidden gcc option but you need to manage what do you
export similarly as it is done in windows marking classes with
default visibility.
However it is quite tricky and this would not work with compiled libraries.
>
> I haven't tried if a -Dboost=boost_1_43 preprocessor flag
> (applied
> to both the boost build and the application build) is
> sufficient,
> though.
There is my small python script that renames boost [1]. It renames
all includes and defines so you can simultaneously use several
boost version in same code.
Also latest BCP version allow you to do similar job, but it does not
rename includes and macros so you can't include two boost version in
same C++ code.
Note: my script was written before BCP provided such option.
**BUT!!!!** It does not solves all problems:
1. There is a code placed in tr1 namespace - it would collide if you use
it.
2. Some libraries that provide extern "C" functions do bad job and pollute
global namespace with these symbols. They collide as well.
Examples:
- Boost.Thread: https://svn.boost.org/trac/boost/ticket/3812
- Boost.Test: https://svn.boost.org/trac/boost/ticket/3811
- LW Thread: https://svn.boost.org/trac/boost/ticket/3810
But in some libraries this behavior is actually design. For example
boost.regex provides POSIX regex API regcomp(A|W), regexec(A|W) that
go directly to global namespace.
(BTW kill me if understand who created this A|W api - POSIX does
not have this nonsense).
It looks like that Boost C++ developers are not really familiar
with correct methods of providing replacement API in C.
So you have to compile boost version without this API manually...
As you can see if I want to use boost.thread even namespace renaming
would not help me till these bugs are fixed.
I hope this helps,
Artyom
P.S.: as you can see it is quite non-trivial issue.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk