Boost logo

Boost :

From: Lois Goldthwaite (loisg_at_[hidden])
Date: 2000-12-22 05:43:14


The mangled names are too long? So make them shorter. I think almost
every compiler has some length limit; it's just that some limits are
long enough you don't notice.

This is hokey but can be very effective:

#ifdef BOOST_SHORT_NAMES_FOR_MSVC
   #define iterator_traits b_i_t
   #define is_pointer b_i_p
   ...

until the name gets short enough to make MSVC happy. The advantage of
this is that you don't have to change any code. The disadvantage is that
the linker sees the short names, so its "missing symbol" messages can be
confusing to people who don't understand the magic.

VC++ versions up to about v4 had a length limit of 248 characters, so
they choked on the template parameters for strings! And compiling things
in debug mode was impossible. That's how I learned this trick.

In fairness to VC++, the old HP compiler used to have a 248 character
limit as well (or it may have been a function of the file system, since
they created temporary files for instantiations). At least that compiler
had some options (-pth -ptb IIRC) which generated arbitrary short names
for templates.

Lois

> Message: 4
> Date: Thu, 21 Dec 2000 10:11:39 -0500
> From: "David Abrahams" <abrahams_at_[hidden]>
> Subject: BGL, iterator_adaptors, VC6, STLport debug mode
>
>
>
> I just spent a few days tracking down a problem which turned out to be that
> this particular combination is poison for me. The symbol names end up going
> past MSVC's arbitrary length limits.
>
> The question is, what to do about it? We could turn off iterator_adaptors
> when __STL_DEBUG and BOOST_MSVC are #defined, but of course with MSVC we run
> a risk of breakdown even without __STL_DEBUG.
>
> I've had some other thoughts:
>
> 1. Change the default type parameter for Traits to void (or something). Then
> detect that it's void inside the class using boost::is_same from
> type_traits, and select boost::iterator_traits<> for a traits_type typedef
> using template "magic". I believe we can easily provide
> boost::iterator_traits<> for compilers without partial specialization by
> using boost::is_pointer<>. This would cut down on the symbol lengths for
> adapted iterators that can use the default Traits parameter, but it wouldn't
> help in cases where an explicit iterator_traits was needed.
>
> 2. The best way to get the symbol names to be really short in many cases is
> to cut down on the number of template parameters to iterator_adaptors. For
> example, we could ask people to deliver the Iterator parameter and Traits as
> typedefs in the Policies class instead of as separate parameters. I'm none
> too fond of this idea, since I believe it will harm usability in generic
> code.
>
> Thoughts?
>
> -Dave
>


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