cygwin支持C ++ 11在g ++ 4.9.2 [英] cygwin support for C++11 in g++4.9.2

查看:324
本文介绍了cygwin支持C ++ 11在g ++ 4.9.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  #include< cmath> 
#include< iostream>

int main()
{
auto x = std :: log2(10);
std :: cout<< x < std :: endl;
}

错误:

  g ++ -std = c ++ 11 test.cpp 
test.cpp:在函数'int main()':
test.cpp:5:11:错误:'log2'不是'std'的成员
auto x = std :: log2(10);
^
test.cpp:5:11:note:建议替代方案:
在包含在/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++ / cmath:44:0,
从test.cpp:1:
/usr/include/math.h:305:15:note:'log2'
extern double log2 _PARAMS双));

这是cygwin的g ++移植中的一个已知错误吗?上面的代码在支持C ++ 11的任何Linux / UNIX风格上都可以正常工作。

解决方案

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

此问题现在通过< cmath> 的补丁修复,也在上面提供的链接。


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.

解决方案

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.

这篇关于cygwin支持C ++ 11在g ++ 4.9.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆