Opened 17 years ago

Closed 17 years ago

Last modified 16 years ago

#532 closed Bugs (None)

multi_index/detail/unbounded.hpp causes problems in MSVC PCH

Reported by: dsmtoday Owned by: joaquintides
Milestone: Component: multi_index
Version: None Severity:
Keywords: Cc:

Description

MSVC 7.1

I integrated a multi_index into my project and have
been very happy with it.  However, compile times for my
class went from milliseconds to five seconds.  And
since this class is a cornerstone of my project, this
time got added to each compile.

To try and speed things up, I put this particular
class's header file in my precompiled header system. 
Well, that worked great, everything compiles fast, but
when it links, there are two static objects defined in
every object file, causing conflicts, so it doesn't
link.  The errors are the same this guy got.  
http://lists.boost.org/boost-users/2004/07/7151.php

What I tried and what works for me, but I'm not sure is
an acceptable long-term solution, was to #define out
two lines which to my eyes appear to define static
objects.  Why this is only a problem for pre-compiled
headers, I don't know.  Anyway, here is what I did to
unbounded.hpp

#if !defined(_MSC_VER)
namespace{

detail::unbounded_type 
unbounded_obj=detail::unbounded_type();
detail::unbounded_type& unbounded=unbounded_obj;

} /* unnamed */
#endif


Change History (5)

comment:1 by joaquintides, 17 years ago

Logged In: YES 
user_id=911241

I have just reproduced the problem you mention, after
googling a bit seems like a known bug of MSVC when
mixing unnamed namespace entities and PCHs.

The solution you propose is not valid, since it
undefines unbounded, which can be used in the range()
member function of ordered indices.

Could you please try replacing your local copy of
boost/multi_index/detail/unbounded.hpp with the
file attached? My tests show this fixes the problem,
I'll be commiting this to the CVS after some
regression tests.

Best,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

comment:2 by dsmtoday, 17 years ago

Logged In: YES 
user_id=1040827

Joaquín -

Thanks for the quick reply.  Your new file worked for me. 
No more link errors when I use the multi_index template in a
pre-compiled header.

Thanks again for the prompt fix!
-todd-

comment:3 by joaquintides, 17 years ago

Status: assignedclosed
Logged In: YES 
user_id=911241

Fixed in CVS. Hope you're enjoying Boost.MultiIndex!

comment:4 by askldjd, 16 years ago

Logged In: YES 
user_id=1712657
Originator: NO

I have encountered the same issue. I had also tried your solution, and it works great.

Would this bug be fixed for Boost 1.34 release?

Thank.

... Alan


comment:5 by joaquintides, 16 years ago

Logged In: YES 
user_id=911241
Originator: NO

Hello Alan,

Yes, this problem is fixed in what will (hopefully soon) become Boost 1.34.
You can check it yourself by downloading a RC_1_34 snapshot from

http://engineering.meta-comm.com/boost/snapshot/boost-RC_1_34_0.tar.bz2 

Best regards,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Note: See TracTickets for help on using tickets.