如何在启用了C ++ 11的xcode 4.6.2中编译<functional> </functional>

时间:2013-06-02 17:14:13

标签: c++ xcode c++11 llvm llvm-clang

我们有.mm文件包含&lt;功能性> (标题标题),它报告以下错误:

In file included from 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/mutex:177:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1672:1: error: cannot declare a class template with no name
class __bind
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1742:35: error: expected expression
struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
                                  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1742:36: error: '_Fp' does not refer to a value
struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
                                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1741:16: note: declared here
template<class _Fp, class ..._BoundArgs>
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1746:20: error: expected class name
    : public __bind<_Fp, _BoundArgs...>
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1746:39: error: expected '{' after base class list
    : public __bind<_Fp, _BoundArgs...>
                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1746:39: error: expected ';' after class
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1746:39: error: expected unqualified-id
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1806:23: error: expected '>'
__bind<_Fp, _BoundArgs...>
                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/functional:1806:26: error: expected unqualified-id
__bind<_Fp, _BoundArgs...>

命令行是

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
-x objective-c++ -arch armv7 -fmessage-length=0 -std=c++11 -stdlib=libc++ -fobjc-arc \
-Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers \
-Wno-missing-prototypes -Wreturn-type -Wno-implicit-atomic-properties \
-Wno-receiver-is-weak -Wno-non-virtual-dtor -Wno-overloaded-virtual \
-Wno-exit-time-destructors -Wformat -Wno-missing-braces -Wparentheses \
-Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter \
-Wunused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized \
-Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion \
-Wno-constant-conversion -Wno-int-conversion -Wno-enum-conversion \
-Wno-shorten-64-to-32 -Wno-newline-eof -Wno-selector -Wno-strict-selector-match \
-Wno-undeclared-selector -Wno-deprecated-implementations -Wno-c++11-extensions ...

有没有解决方法?

1 个答案:

答案 0 :(得分:2)

此类错误通常不是由<functional>引起的,否则全世界都会报告错误。更可能的原因是你的一个标题做了一些它不应该做的事情,这会在以后引起问题。例如。 #define __bind会产生这种错误,这显然是非法的。