【问题标题】:'to_string' is not a member of 'std' [duplicate]“to_string”不是“std”的成员[重复]
【发布时间】:2014-04-06 02:29:19
【问题描述】:

我用 mingw 编译项目,项目是很酷的编译器。 这是我的代码的一部分

#include "astnodecodegenerator.hpp"
#include "utility.hpp"
#include "constants.hpp"
#include <string>
#include <cmath>
#include <sstream>
#include <stack>

。 . . .

void AstNodeCodeGenerator::visit(StringConst& str) 
{ 
    emit_la("a0", (std::string("str_const") + std::to_string(stringtable().get_idx(str.token.get_val()))).c_str());
}

void AstNodeCodeGenerator::visit(IntConst& int_const) 
{
    emit_la("a0", (std::string("int_const") + std::to_string(inttable().get_idx(int_const.token.get_val()))).c_str());
}

错误是:

error :'to_string' is not a member of 'std' emit_la<"a0",<std::string(("str_const") + std::to_string(stringtable().get_idx(str.token.get_val()))).c_str());

【问题讨论】:

  • to_string 是 C++11 功能。您可能需要打开它。
  • 在命令行使用-std=c++11开启C++11。
  • 这是makefile的一部分:----CFLAGS=-g -Wall -Wextra -std=c++11 -Wno-write-strings ../../include/boost跨度>
  • 你的意思是什么?

标签: c++ compiler-errors mingw c++-standard-library


【解决方案1】:

MinGW 不支持它,因为 MinGW 运行时的限制需要 MinGW 开发人员进行更改。

看看这些:

如果您可以使用 Boost,一个不错的选择是 boost::lexical_cast(去过那里,做过)。

【讨论】:

  • 让 mingw 开发人员取得任何进展......关于这个 1571 的最后一个错误帖子由于“过时”而被“关闭”,但这是 2014 年 12 月,我仍然遇到这个问题!@!! !啊啊拉头发!!!!
  • @BrianJack 它的 2017 年,仍然开始:D
猜你喜欢
  • 2013-10-07
  • 2020-05-23
  • 2014-11-23
  • 2012-10-10
相关资源
最近更新 更多