Cygwin不编译stod [英] Cygwin not compiling stod

查看:334
本文介绍了Cygwin不编译stod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译此示例代码

#include <iostream>   // std::cout
#include <string>     // std::string, std::stod

int main ()
{
  std::string orbits ("365.24 29.53");
  std::string::size_type sz;     // alias of size_t

  double earth = std::stod (orbits,&sz);
  double moon = std::stod (orbits.substr(sz));
  std::cout << "The moon completes " << (earth/moon) << " orbits per Earth year.\n";
  return 0;
}

尝试从命令提示符处编译

Trying to compile from the command prompt gives

C:\Users\DWane\Documents>g++ -std=c++0x testme.cpp -o out.exe
testme.cpp: In function 'int main()':
testme.cpp:9:18: error: 'stod' is not a member of 'std'
   double earth = std::stod (orbits,&sz);
                  ^
testme.cpp:10:17: error: 'stod' is not a member of 'std'
   double moon = std::stod (orbits.substr(sz));
                 ^

我运行Windows 8 64位,并有g ++(GCC)4.8.3 。

I'm running Windows 8 64bit and have g++ (GCC) 4.8.3.

推荐答案

简短的回答是,它是Cygwin的GCC端口(或libstdc ++)中的一个错误。我可以在Cygwin邮件列表上找到的唯一消息来自 2014年1月29日 a>并且它只是说:

The short answer is that it's a bug within Cygwin's port of GCC (or libstdc++). The only message I can find on the Cygwin mailing list is from Jan 29, 2014 and it merely says:


您是否尝试过在mingw下的同样问题的建议?它看起来
这样可能是一个临时的解决方法,直到问题解决。
只要

Did you try the suggestion for the same problem under mingw? It looks like this could be a temporary workaround until the problem is fixed. Just make

确定你试试
/lib/gcc/i686-pc-cygwin/4.8.2/include/c++/bits /basic_string.h如果
正在为Cygwin构建。

sure you try it on /lib/gcc/i686-pc-cygwin/4.8.2/include/c++/bits/basic_string.h if you're building for Cygwin..

MinGW已知有字符串转换问题功能,即使它不同于Cygwin。我的建议是下载Stephan T. Lavavej的 64位MinGW分发,它附带GCC 4.9.1和许多最新包。

MinGW has been known to have issues with string conversion functions as well, even though it's different from Cygwin. My suggestion is to download Stephan T. Lavavej's 64-bit MinGW distribution which comes with GCC 4.9.1 and many up to date packages.

这篇关于Cygwin不编译stod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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