'log2' is not a member of 'std'
jmr at macports.org
Sun Jul 2 17:28:30 UTC 2017
> This is MacOSX 10.6.8 running various compilers provided by MacPorts.
> Compiling the following C++ source
> #include <cmath>
> int main(void)
> double d = std::log2(2.3456789f);
> return 0;
> results in
> 'log2' is not a member of 'std'.
> This happens with the system g++, which is i686-apple-darwin10-g++-4.2.1,
> each of g++-4.0 g++-4.2 g++-mp-5 g++-mp-6, and with clang++-mp-3.4;
> in each case, I am compiling as $CXX -std=c++11 prog.c
> Apparently, there is some relatively recent turmoil about the C++ libs;
> I don't know much c++ but find myself compiling some third party C++ code.
> Am I missing something obvious?
Well the Xcode-supplied g++s and clang would be using the system
libstdc++, which doesn't support C++11, and std::log2 is a C++11 feature.
The g++-mp variants should support it, but seemingly don't because of
the bug that Ken mentioned, which should be fixed in GCC 7.
Clang can support C++11 if you use -stdlib=libc++.
More information about the macports-users