我不确定我在这里看到了什么。下面的测试结果来自运行 OS X 10.5.8 的旧 PowerMac G5。它仍然可以在大端 PowerPC cpu 下进行测试。编译器是 GCC 5.4,它由 MacPorts 提供。
测试程序如下。编译它会导致错误error: 'log2' is not a member of 'std'
。
$ cat test.cxx
#include <cmath>
int main(int argc, char* argv[])
{
double d = std::log2(2.3456789f);
return 0;
}
根据是 std::log2() 是扩展还是 C++ 标准?,std::log2
应该可用。
为什么程序编译失败?
$ /opt/local/bin/g++-mp-5 --version
g++-mp-5 (MacPorts gcc5 5.4.0_0) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
$ /opt/local/bin/g++-mp-5 -std=c++11 test.cxx -o test.exe
test.cxx: In function 'int main(int, char**)':
test.cxx:4:16: error: 'log2' is not a member of 'std'
double d = std::log2(2.3456789f);
^
test.cxx:4:16: note: suggested alternative:
In file included from /usr/include/math.h:26:0,
from /opt/local/include/gcc5/c++/cmath:44,
from test.cxx:1:
/usr/include/architecture/ppc/math.h:431:15: note: 'log2'
extern double log2( double );
^
这可能与旧硬件有关:C++11 cmath 函数不在 std 命名空间中,用于 android NDK w/gcc-4.8 或 clang 3.4。我意识到 Android 是一个不同的平台。
现在在 MacPorts 问题跟踪器中打开:Issue 53226: PowerMac, GCC 5.4 and "error: 'std::log2' has not been declared"。
现在在 GCC 问题跟踪器中打开:Issue 79017: Old PowerMac G5, MacPorts GCC 5.4, C++11 and "std::log2 has not been declared"