jww*_*jww 15 c++ macos shared-ptr
我似乎在这里遗漏了一些东西.我搬到boost::shared_ptr了std::shared_ptr.shared_ptr早在2000年代中期就已成为TR1的一部分,它应该会在2012年的所有地方推出.
试图shared_ptr在Apple下使用我得到了一些未定义的引用:
SecureArray.h:26:12: error: no member named 'shared_ptr' in
namespace 'std'
using std::shared_ptr;
~~~~~^
SecureArray.h:27:12: error: no member named 'tr1' in namespace
'std'
using std::tr1::shared_ptr;
~~~~~^
SecureArray.h:487:5: error: unknown type name 'shared_ptr'
shared_ptr<SecureVector> m_vector;
Run Code Online (Sandbox Code Playgroud)
典型的编译器命令如下(GCC和Clang都失败):
clang++ -g2 -ggdb -O0 -fcatch-undefined-cxx0x-behavior
-DSAFEINT_DISALLOW_UNSIGNED_NEGATION=1 -pipe -std=c++0x -Wall -Wextra
-Wno-unused-parameter -Wno-tautological-compare
-I. -I./esapi -I./deps -I/usr/local/include -I/usr/include -fpic
-c src/DummyConfiguration.cpp -o src/DummyConfiguration.o
Run Code Online (Sandbox Code Playgroud)
我试图将其包括如下(我相信我需要调整它,但我不记得C++语法说"看这里,或看看那里"):
#include <memory>
using std::shared_ptr;
using std::tr1::shared_ptr;
Run Code Online (Sandbox Code Playgroud)
Apple的手册页没有任何结果:
$ man shared_ptr
No manual entry for shared_ptr
$ man -k shared_ptr
shared_ptr: nothing appropriate
Run Code Online (Sandbox Code Playgroud)
我安装了Mac OS X 10.8(完全修补),Xcode(完全修补)和命令行工具.
那么如何在Apple平台上使用std :: shared_ptr呢?
Hug*_*ugh 22
#include <tr1/memory>将使用libstdc ++与任一编译器一起使用.或者,与Clang:
#include <memory>
using std::shared_ptr;
Run Code Online (Sandbox Code Playgroud)
并编译c++ -std=c++11 -stdlib=libc++ ....我不知道为什么Clang默认使用libstdc ++; 大概是GCC的兼容性.
您找不到手册页,因为libstdc ++没有手册页.有帮助,不是吗 源代码分发中有HTML文档.
| 归档时间: |
|
| 查看次数: |
10261 次 |
| 最近记录: |