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 project settings for your VS2010 project.

Edit: The define was in error set to _HAS_CPP0X=1. It should be _HAS_CPP0X=0 to disable TR1 headers from Visual Studio 2010.

Related posts:

  1. User warnings for MS Visual Studio
  2. Visual Studio: fatal error LNK1201: error writing to program database ‘…’ check for insufficient disk space, invalid path, or insufficient privilege
  3. Say goodbye to memory leaks in C++ with Boost!
  4. Making a game
  5. Building opensource Qt on Windows

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!

  2. kent says

    Thanks!

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

Leave a Reply

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