我的MacOS版本是12.2.1,sdk是12.1,我以前可以成功地构建它,但是现在它在我完成xcode升级之后就失败了。
这是一些错误信息。
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/vector:276:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__bit_reference:15:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/algorithm:653:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/memory:676:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/iterator:419:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:80:16: error: no template named 'unary_function'; did you mean 'binary_function'?
static unary_function<_Ap, _Rp>
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:27:29: note: 'binary_function' declared here
struct _LIBCPP_TEMPLATE_VIS binary_function
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:80:16: error: too few template arguments for class template 'binary_function'
static unary_function<_Ap, _Rp>
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:27:29: note: template is declared here
struct _LIBCPP_TEMPLATE_VIS binary_function
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:81:31: error: no template named 'unary_function'; did you mean 'binary_function'?
__test(const volatile unary_function<_Ap, _Rp>*);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:27:29: note: 'binary_function' declared here
struct _LIBCPP_TEMPLATE_VIS binary_function
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:81:31: error: too few template arguments for class template 'binary_function'
__test(const volatile unary_function<_Ap, _Rp>*);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:27:29: note: template is declared here
struct _LIBCPP_TEMPLATE_VIS binary_function
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:168:14: error: no template named 'unary_function'; did you mean 'binary_function'?
: public unary_function<_A1, _Rp>
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__functional_base:27:29: note: 'binary_function' declared here
struct _LIBCPP_TEMPLATE_VIS binary_function
我的心愿是
cmake_minimum_required(VERSION 3.0)
project(mytest VERSION 1.0.0)
cmake_policy(SET CMP0074 NEW)
set(CMAKE_CXX_STANDARD 11)
add_compile_options(-stdlib=libc++)
发布于 2022-03-04 06:58:44
默认情况下,与实际xcode一起提供的clang支持C++17。
std::unary_function
在C++17中被删除。应该使用std::function
。
你set(CMAKE_CXX_STANDARD 11)
太迟了。它应该放在project(mytest VERSION 1.0.0)
之前,否则默认的标准C++17设置为完美。
https://stackoverflow.com/questions/71346528
复制相似问题