macOS Monterey下引入<cmath>编译报错:未找到numeric_limits模板
编译仅含
#include <cmath>的C++程序报错的解决方案求助 运行仅包含一行#include <cmath>的C++程序时编译失败,报错信息如下:
% g++ cmath-bug.cpp In file included from cmath-bug.cpp:1: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:26: error: no template named 'numeric_limits' bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits), ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:60: error: no template named 'numeric_limits' bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits), ...... /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:664:12: error: use of undeclared identifier '_Lim' return _Lim::max(); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:665:21: error: use of undeclared identifier '_Lim' } else if (__r <= _Lim::lowest()) { ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:666:12: error: use of undeclared identifier '_Lim' return _Lim::min(); ^ 11 errors generated.
已查找相关讨论帖子但问题仍未解决,系统及环境信息如下:
% xcode-select -p /Library/Developer/CommandLineTools % g++ -Wp,-v -E - clang -cc1 version 14.0.0 (clang-1400.0.29.202) default target x86_64-apple-darwin21.6.0 ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include" ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/include /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /Library/Developer/CommandLineTools/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory) End of search list.
恳请各位提供解决方案或建议!
内容的提问来源于stack exchange,提问作者Peter
相关产品推荐
相关产品推荐

