Cygwin:g ++ 5.2:'to_string'不是'std'的成员

时间:2015-11-03 13:13:24

标签: c++ c++11 gcc cygwin

以下简单程序无法使用gcc

在cygwin中编译
#include <string>
#include <iostream>

int main()
{
  std::cout << std::to_string(4) << std::endl;
  return 0;
}

命令行:

$ g++ -std=c++0x to_string.cc

错误:

to_string.cc: In function ‘int main()’:
to_string.cc:6:16: error: ‘to_string’ is not a member of ‘std’
   std::cout << std::to_string(4) << std::endl;

G ++版:

$ g++ --version
g++ (GCC) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

可以在Ubuntu中编译相同的代码。

是否可以使用cygwin编译此代码,或者我需要编写一个解决方法?

1 个答案:

答案 0 :(得分:-1)

你在这里混合gcc和g ++

引用Mike F:&#34;默认值中最重要的差异是它们自动链接哪些库。&#34;

What is the difference between g++ and gcc?