0

我们有一个 .mm 文件包含 <functional> (一个标准头),它报告以下错误:

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 ...

有什么解决方法吗?

4

1 回答 1

2

此类错误一般不是由 引起的<functional>,否则全世界都会报告它们。更可能的原因是您的一个标头做了不应该做的事情,这随后导致了问题。eg#define __bind会产生这里看到的那种错误,显然是非法的。

于 2013-06-02T22:18:45.340 回答