eclipse中的unique_ptr自动完成 [英] unique_ptr autocomplete in eclipse

查看:181
本文介绍了eclipse中的unique_ptr自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩unique_ptr。在我的上次发布中,人们帮助我编译了一个使用此指针的程序,方法是指定-std =编译期间的c ++ 0x。
现在我想知道是否有任何方法来指示eclipse在自动完成时考虑c ++ 11?

unique_ptr不在std :: namespace列表中,也不可以找到与unique_ptr相关联的方法(重置,移动...)。



谢谢
vahid

解决方案

内存头(可能在/usr/include/c++/4.9/memory中找到)只包含unique_ptr.h和shared_ptr.h(可能在如果宏__cplusplus等于或大于201103L,则/usr/include/c++/4.9/bits/unique_ptr.h和/usr/include/c++/4.9/bits/shared_ptr.h)。检查memory.h自己在第69行(或搜索字符串#if __cplusplus> = 201103L)中查看#if预处理器条件。



正如其他人所提到的,使用-std = c ++ 0x或更高版本的c ++标准(-std = c ++ 11或-std = c ++ 14)进行编译可以解决编译错误,而不是eclipse索引和自动完成问题



为了解决eclipse索引问题,我将__cplusplus预处理器宏添加到项目构建属性中,值为201103L,之后我刷新了索引;



添加预处理器宏:



右键单击项目资源管理器上的项目>>属性>> C / C ++一般>>预处理器包括>>条目>> GNU C ++ >> CDT用户设置条目>>添加... >>预处理器宏;



然后输入宏名称__cplusplus和值201103L;



之后,要刷新索引,请执行以下操作:



项目浏览器右键单击项目>> Inde x >> Rebuild;



Ps .:我在使用gcc 4.9.2和eclipse Luna(4.4.2),在ubuntu 15.04 64bits


I am playing with unique_ptr. In my last post people helped me compiling a program that used this pointer by specifying the -std=c++0x during compilation. Now i was wondering if there is any way to instruct eclipse to consider c++11 while auto-completing?
unique_ptr is not coming in the list of std:: namespace, nor I can find the methods (reset, move...) associated with a unique_ptr.

Thank you vahid

解决方案

The "memory" header (probably found at /usr/include/c++/4.9/memory) only includes "unique_ptr.h" and "shared_ptr.h" (probably found at /usr/include/c++/4.9/bits/unique_ptr.h and /usr/include/c++/4.9/bits/shared_ptr.h) if the macro "__cplusplus" is equal or greather than "201103L". Check memory.h for yourself to see the "#if" preprocessor condition there, at line 69 (or search for the string "#if __cplusplus >= 201103L").

As others mentioned, compiling with "-std=c++0x" or later c++ standards (-std=c++11 or -std=c++14) solves the compilation errors, but not the eclipse indexing and autocomplete problem.

To solve the eclipse indexing issue I added the "__cplusplus" Preprocessor Macro to the project build properties, with the value "201103L", and afterwards I refreshed the index;

To add the preprocessor macro:

"right click the project on project explorer" >> properties >> C/C++ General >> Preprocessor Includes >> Entries >> GNU C++ >> CDT User Settings Entries >> Add... >> Preprocessor Macro;

Then entry a macro with name "__cplusplus" and value "201103L";

Afterwards, to refresh the index, do:

"right click project on project explorer" >> Index >> Rebuild;

Ps.: I was using gcc 4.9.2 and eclipse Luna (4.4.2), on ubuntu 15.04 64bits

这篇关于eclipse中的unique_ptr自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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