1
我試圖編譯我的遺留免費libFoundation項目,位於https://github.com/chmeeedalf/lf-foundation,但遇到使用clang 3.4和libC++的問題。看來自己是不是快樂與容器ARC,我看到下面的錯誤摘錄:Objective-C++ ARC和C++容器
In file included from /home/chmeee/git-lffoundation/src/Collections/NSCoreArray.mm:34:
In file included from /home/chmeee/git-lffoundation/src/../Headers/Foundation/NSArray.h:31:
In file included from /home/chmeee/git-lffoundation/src/../Headers/Foundation/NSObject.h:40:
In file included from /home/chmeee/git-lffoundation/src/../Headers/Foundation/NSRange.h:192:
In file included from /usr/include/c++/v1/algorithm:627:
/usr/include/c++/v1/memory:913:17: error: call to 'addressof' is ambiguous
{return _VSTD::addressof(__r);}
^~~~~~~~~~~~~~~~
/usr/include/c++/v1/__config:341:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
^
/usr/include/c++/v1/vector:1678:65: note: in instantiation of member function 'std::__1::pointer_traits<const __strong id *>::pointer_to' requested here
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
^
/home/chmeee/git-lffoundation/src/Collections/NSCoreArray.mm:115:8: note: in instantiation of member function 'std::__1::vector<id, std::__1::allocator<id> >::insert' requested here
items.insert(items.begin() + index, anObject);
^
/usr/include/c++/v1/__functional_base:96:1: note: candidate function [with _Tp = const id]
addressof(__strong _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:122:1: note: candidate function [with _Tp = const id]
addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:83:1: note: candidate function [with _Tp = const id]
addressof(_Tp& __x) _NOEXCEPT
^
1 error generated.
*** Error code 1
Stop.
make: stopped in /home/chmeee/git-lffoundation/src
Exit 1
本例中的文件有一個std::vector
聲明:
std::vector<id> items;
有人能提供一些線索解決這個問題?我試圖在std::vector
聲明中添加一個明確的__strong
,但沒有用,但__unsafe_unretained
的確消除了錯誤。
我使用的是基於libC++和clang 3.4的FreeBSD CURRENT。
是否'的std ::矢量<__strong id> items'或'的std ::矢量<__ unsafe_unretained ID> items'工作? –
'std :: vector items;'適合我。與clang版本的Xcode 5.0.2:Apple LLVM版本5.0(clang-500.2.79)(基於LLVM 3.3svn) –
@GregParker:不,它不。我試過'std :: vector <__strong id> items',得到了同樣的結果。 – chmeee