Eclipse:函数'to_string'无法解析 [英] Eclipse: function 'to_string' could not be resolved

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

问题描述


可能重复:

关闭eclipse错误(这不是真的错误)


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



根据 cppreference std :: to_string 函数在< string> 中定义,所以我将它明确地包含在被指控的 .cpp 文件中。我也试过这个这个解决方案,没有运气。



任何其他建议?



编辑:



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

解决方案

更新:自从我发布原始答案已经很久了它已经过时了。我今天(2014年3月15日)仔细检查:在Eclipse Kepler(Build id 20130614-0229)中,只要




  • 在项目>属性>C / C ++构建>设置下添加,然后在工具设置选项卡上添加GCC C ++编译器>其他 -std = c ++ 11 标志,


  • 然后在窗口>首选项> C / C ++> Build 发现选项卡上的设置选择了CDT GCC内置编译器设置,并添加 -std = c ++ 11 code>标志为命令获取编译器规范。在我的机器上,更改后看起来像这样:



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


  • 清理并重建您的项目您的索引(<因为Eclipse倾向于缓存错误消息并显示它们,即使在更改设置后它们不见了。




这可以在我的机器上运行。如果不在你的机器上,那么你可能想给一个镜头: 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:函数'to_string'无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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