no type named 'shared_ptr' in namespace &#

2020-03-24 09:37发布

Hopefully this helps somebody else

Trying to compile an iOS project with Cedar BDD kept failing with no type named 'shared_ptr' in namespace 'std' error message. It was obviously a C++ error but couldn't understand why the C++ library Xcode was using didn;t have the shared_ptr type defined until I discovered the build settings of the target provides two libraries to choose from

  • libstdc++ (compiler default)
  • libc++

3条回答
戒情不戒烟
2楼-- · 2020-03-24 09:48

Apple ship a very old version of libstdc++ that doesn't support C++11, so if you use libstdc++ you can't use C++11 features.

查看更多
啃猪蹄的小仙女
3楼-- · 2020-03-24 09:58

selecting libc++ fixes the problem see screenshotXcode 4.4 build settings window

查看更多
不美不萌又怎样
4楼-- · 2020-03-24 10:07

In xcode you must use #include <memory>, you can not use #include <memory.h>. Please check this.

查看更多
登录 后发表回答