Which shared_ptr to use?

2012-05-05
2013-06-12
  • I was trying to build Console2 using VS 11 Beta.
    I got this errors:

    1>---- Rebuild All started: Project: Console, Configuration: Release Win32 ----
    1>  stdafx.cpp
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(51): error C2872: 'shared_ptr' : ambiguous symbol
    1>          could be 'C:\boost_1_49_0\boost/smart_ptr/shared_ptr.hpp(165) : boost::shared_ptr'
    1>          or       'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\memory(456) : std::shared_ptr'
    1>          c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(64) : see reference to class template instantiation 'SharedMemory<T>' being compiled
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(58): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(59): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(61): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(62): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(63): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(87): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\../shared/SharedMemory.h(453): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\Helpers.h(20): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\Helpers.h(117): error C2872: 'shared_ptr' : ambiguous symbol
    1>c:\users\andre\desktop\console2\console\ConsoleHandler.h(69): error C2872: 'shared_ptr' : ambiguous symbol

    Which shared_ptr to use? The one from VC, or from Boost?

     
  • I added this part on SharedMemory.h

    And then I got these errors:

    1>---- Build started: Project: ConsoleHook, Configuration: Release Win32 ----
    2>---- Build started: Project: Console, Configuration: Release Win32 ----
    2>  stdafx.cpp
    1>  stdafx.cpp
    2>../wtl/wtl/include\atlapp.h(576): error C2039: 'AtlGetCommCtrlVersion' : is not a member of 'ATL'
    2>../wtl/wtl/include\atlapp.h(576): error C3861: 'AtlGetCommCtrlVersion': identifier not found
    1>  ConsoleHandler.cpp
    1>ConsoleHandler.cpp(859): error C2668: 'boost::bind' : ambiguous call to overloaded function
    1>          C:\boost_1_49_0\boost/bind/bind.hpp(1330): could be 'boost::_bi::bind_t<R,F,L> boost::bind<BOOL,BOOL(__stdcall *)(HANDLE,LPVOID,SIZE_T,DWORD),HANDLE,boost::arg<I>,int,int>(F,A1,A2,A3,A4)'
    1>          with
    1>          [
    1>              R=BOOL,
    1>              F=BOOL (__stdcall *)(HANDLE,LPVOID,SIZE_T,DWORD),
    1>              L=boost::_bi::list4<boost::_bi::value<HANDLE >,boost::arg<1>,boost::_bi::value<int>,boost::_bi::value<int>>,
    1>              I=1,
    1>              A1=HANDLE,
    1>              A2=boost::arg<1>,
    1>              A3=int,
    1>              A4=int
    1>          ]
    1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\functional(1389): or       'std::_Bind<_Forced,_Ret,_Fun,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>> std::bind<BOOL,BOOL(__stdcall &)(HANDLE,LPVOID,SIZE_T,DWORD),HANDLE,boost::arg<I>&,int,int>(_Fun,_V0_t &&,_V1_t,_V2_t &&,_V3_t &&)'
    1>          with
    1>          [
    1>              _Forced=true,
    1>              _Ret=BOOL,
    1>              _Fun=BOOL (__stdcall &)(HANDLE,LPVOID,SIZE_T,DWORD),
    1>              _V0_t=HANDLE,
    1>              _V1_t=boost::arg<1> &,
    1>              _V2_t=int,
    1>              _V3_t=int,
    1>              _V4_t=std::_Nil,
    1>              _V5_t=std::_Nil,
    1>              <unnamed-symbol>=std::_Nil,
    1>              I=1
    1>          ]
    1>          while trying to match the argument list '(BOOL (__stdcall *)(HANDLE,LPVOID,SIZE_T,DWORD), HANDLE, boost::arg<I>, int, int)'
    1>          with
    1>          [
    1>              I=1
    1>          ]
    1>ConsoleHandler.cpp(859): error C2660: 'boost::shared_ptr<T>::reset' : function does not take 2 arguments
    1>          with
    1>          [
    1>              T=wchar_t
    1>          ]
    1>  ConsoleHook.cpp
    3>---- Build started: Project: ConsoleWow, Configuration: Release Win32 ----
    3>  stdafx.cpp
    3>  ConsoleWow.cpp
    3>  Generating code
    3>  Finished generating code
    1>  Generating Code…
    3>  ConsoleWow.vcxproj -> C:\Users\Andre\Desktop\Console2\ConsoleWow\..\bin\Win32\Release\ConsoleWow.exe
    3>  The system cannot find the path specified.
    3>          0 file(s) copied.
    3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(125,5): error MSB3073: The command "copy ..\bin\Win32\Release\ConsoleWow.exe ..\bin\x64\Release\
    3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(125,5): error MSB3073: :VCEnd" exited with code 1.
    ========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped ==========

     
  • I mean this line:
    #define shared_ptr boost::shared_ptr