私はここで何を見ているのか分かりません。以下のテスト結果は、OS X 10.5.8を実行している古いPowerMac G5のものです。ビッグエンディアンのPowerPC cpuのテストのためにまだそれがあります。コンパイラはGCC 5.4であり、MacPortsによって提供されています。エラー: 'log2'は 'std'のメンバーではありません
テストプログラムは以下のとおりです。コンパイルするとエラーになります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;
}
Is std::log2() an extension or C++ standard?によると、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 functions not in std namespace for android NDK w/gcc-4.8 or 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"
あなたがMacである考えると、あなたは4.2ヘッダを使用していないことを確認してください。 –
@BaummitAugen - '/ .../opt/local/include/gcc5/C++/cmath' *は期待されるヘッダを使用していますか? – jww
私はOSX 10.11.4(Intel i7)で、g ++ - 6(Homebrew経由でインストールされている)とclang ++の両方で試してみました。コンパイルして正常に動作します。 – fedepad