Visual Studio 2010, TR1 and Boost.

Posted by kent at 4 June 2010

Category: c++

Tags: , ,

When porting projects from Visual Studio 2008 or earlier to Visual Studio 2010, and you’re using boost::shared_ptr or other features present in TR1, there will be conflicts. Boost has their own implementation of shared_ptr in boost::shared_ptr and with VS2010 they have put shared_ptr in std::tr1 and they have made shared_ptr available through std::shared_ptr. When using using namespace std; and using namespace boost; there will be ambiguities.

To disable the C++0x/TR1 headers from VS2010 and use the boost implementation, define _HAS_CPP0X=0 in the preprocessor project settings for your VS2010 project. 

Select "All Configurations" and then add the preprocessor directive.

VN:F [1.9.13_1145]
Rating: 5.0/5 (3 votes cast)
Visual Studio 2010, TR1 and Boost., 5.0 out of 5 based on 3 ratings
Share

No related posts.

2 Comments

  1. Rick.Renfrew says

    Just a heads up, I stumbled across this blog post when trying to do exactly what you were talking about (disable TR1 in VS2010). I actually had to set _HAS_CPP0X to 0, though, instead of 1 in order to disable the built-in TR1 implementation so I could use boost.

    I found several places that said to set the macro to 1, so I’m not sure if this was changed recently or something like that. In either case, I figured I’d post this here, hopefully it’ll help whoever comes across this next :D . Thanks for the informative post!

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
  2. kent says

    Thanks!

    It should of course be _HAS_CPP0X=0 to disable the headers. My mistake.

    VN:F [1.9.13_1145]
    Rating: 3.0/5 (1 vote cast)

Leave a Reply

Leave a Reply
  • (required)
  • (required) (will not be published)