cygwin support for C++11 in g++4.9.2

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

I am trying to test some C++11 code on Windows 7 under cygwin, and am getting compiling errors for functions that are defined starting with C++11, such as std::log2 and std::round. I am compiling with g++ -std=c++11 test.cpp, using gcc 4.9.2. Here is some minimal example that fails to compile:

#include <cmath> #include <iostream>  int main() {         auto x = std::log2(10);         std::cout << x << std::endl; }

error:

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));

Is this a known bug in cygwin's g++ porting? The code above works fine on any Linux/UNIX flavour supporting C++11.

回答1:

The issue seems to be a bug related to cygwin implementation, thanks to Shafik Yaghmour for pointing it out.

The issue is now fixed via a patch for <cmath>, also at the link provided above.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!