Eclipse:function'to_string'无法解决 [英] Eclipse: function 'to_string' could not be resolved

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

问题描述


可能重复:















b $ b

我面对这个恼人的问题:Eclipse拒绝识别 std :: to_string 函数,但我的程序编译没有错误。我缺少什么?



根据 cppreference std :: to_string 函数在< string> 中定义, incriminated .cpp 文件。我也尝试过解决方案,没有运气。



任何其他建议?



编辑:



我使用g ++ 4.7。 2在Linux下。

解决方案

更新:它已经过时了。我今天(2014年3月15日)仔细检查:在Eclipse Kepler(Build id 20130614-0229)中,足以




  • 工具 c> -std = c ++ 11 标志,


  • > 选项卡上选择 CDT GCC内置编译器设置并添加 -std = c ++ 11 code>标志到命令以获取编译器规格。在我的机器上,更改后看起来像这样:



    $ {COMMAND} -E -P -v -dD -std = c ++ 11$ {INPUTS}


  • 清除并重建您的项目


>

这在我的机器上可以正常工作。如果它不在你的机器上,那么你可能想要拍摄这个: C++11 Eclipse上的完全支持虽然我既不确定这种方法的正确性,也不需要在我的机器上这样做。自2014年3月7日起,用户声明它帮助他们,而上述方法没有。






原始讯息,现已过期:





似乎你遇到了Codan的常见问题,请参阅我要回答这里






这不是100 %清除如何代码编译。在Eclipse中?或者从命令行,正确设置标志?所以只是在情况下:



您使用的是C ++ 11函数。是否将 -std = c ++ 0x -std = c ++ 11 标志传递给编译器(假设gcc)?



您可能还需要将 __ GXX_EXPERIMENTAL_CXX0X __ 添加到您的定义(再次假设gcc)并重新启动Eclipse。 p>


Possible Duplicate:
Turn off eclipse errors (that arent really errors)

I'm facing this annoying issue: Eclipse refuses to recognize the std::to_string function, but my program compiles without errors. What am I missing?

According to cppreference the std::to_string function is defined in <string>, so I included it explicitly in the incriminated .cpp file. I also tried this, this and this solutions, with no luck.

Any other suggestions?

EDIT:

I'm using g++ 4.7.2 under Linux.

解决方案

UPDATE: It's been a long time since I posted the original answer and it has become outdated. I double-checked today (Mar 15, 2014): in Eclipse Kepler (Build id 20130614-0229) it is sufficient to

  • add under Project > Properties > C/C++ Build > Settings then on the Tool Settings tab GCC C++ Compiler > Miscellaneous the -std=c++11 flag,

  • then under Window > Preferences > C/C++ > Build > Settings on the Discovery tab chose CDT GCC Built-in Compiler Settings and add the -std=c++11 flag to Command to get compiler specs. On my machine it looks like this after the change:

    ${COMMAND} -E -P -v -dD -std=c++11 "${INPUTS}"

  • clean and rebuild both your project and your index (Project > C/C++ Index > Rebuild) as Eclipse tends to cache error messages and show them even though they are gone after changing the settings.

This works on my machine for sure. If it doesn't on yours, then you might want to give a shot to this: C++11 full support on Eclipse although I am neither sure about the correctness of this approach nor was it necessary to do it on my machine. As of March 7, 2014 users claim that it helped them whereas the above approach didn't.


The original post, now outdated:

It seems like you have run into the common problem with Codan, see my answer here.


It isn't 100% clear how the code compiles. Within Eclipse? Or from command line, properly setting the flags? So just in case:

You are using a C++11 function. Do you pass the -std=c++0x or the -std=c++11 flags to the compiler (assuming gcc)?

You might have to also add __GXX_EXPERIMENTAL_CXX0X__ to your defines (again, assuming gcc) and restart Eclipse.

这篇关于Eclipse:function'to_string'无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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