cygwin对g ++ 4.9.2中C++ 11的支持

vso*_*tco 5 c++ cygwin c++11

我试图在cygwin下的Windows 7上测试一些C++ 11代码,并且正在为从C++ 11开始定义的函数编译错误,例如std::log2std::round.我正在编译g++ -std=c++11 test.cpp,使用gcc 4.9.2.这是一些无法编译的最小示例:

#include <cmath>
#include <iostream>

int main()
{
        auto x = std::log2(10);
        std::cout << x << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

错误:

g++ -std=c++11 test.cpp
test.cpp: In function ‘int main()’:
test.cpp:5:11: error: ‘log2’ is not a member of ‘std’
  auto x = std::log2(10);
           ^
test.cpp:5:11: note: suggested alternative:
In file included from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/cmath:44:0,
                 from test.cpp:1:
/usr/include/math.h:305:15: note:   ‘log2’
 extern double log2 _PARAMS((double));
Run Code Online (Sandbox Code Playgroud)

这是cygwin的g ++移植中的已知错误吗?上面的代码适用于任何支持C++ 11的Linux/UNIX风格.

vso*_*tco 3

该问题似乎是与 cygwin 实现相关的错误,感谢 Shafik Yaghmour 指出。

该问题现已通过 的补丁解决<cmath>,同样在上面提供的链接中。