的C ++ 0x编译但即使-gnu Eclipse编辑器错误++ 0x中发现 [英] c++0x compiles but eclipse editor errors even with -gnu++0x discovery
问题描述
我用一些code。使用的std ::时辰:: high_resolution_clock ...的的C ++ 0x的一部分来报告任务的持续时间。
我可以使用-gnu ++ 0x中旗成功编译在Eclipse CDT的的C ++ 0x功能。虽然成功地编译,编辑似乎没有意识到的的C ++ 0x即,它显示在我的code任何的C ++ 0x功能的错误。我解决了通过添加-gnu ++ 0x中标志,以我的项目发现选项。注意:不显示固定的,直到你做一套编译和重建索引...
-E -P -v -dD$ {} plugin_state_location /specs.cpp-std = GNU ++ 0x中
块引用>我仍然有我不能摆脱自己的符号duration_cast无法解析(我有一个图片,但是新用户不能发布图片)
最后一个编辑器错误人对如何解决这一问题的任何想法?这里是code:
的#ifndef _scoped_timer_h_
#定义_scoped_timer_h_#包括LT&;&iostream的GT;
#包括LT&;&计时GT;
#包括升压/ noncopyable.hpp
#包括升压/ format.hpp使用命名空间std ::计时; //计时和记录速度的实用工具类
//(即的事每秒)。
// NB _any_析构函数invokation(包括早期的回报
//从函数或异常抛出),将触发
//输出,将假定任何被测量
//已成功和全面完成。
类scoped_timer:升压::不可复制
{
上市:
scoped_timer(
常量标准::字符串&安培;什么,
常量标准::字符串&安培;单位,
双ñ
)
:_什么什么)
,_units(单位)
,_how_many(N)
,_start(high_resolution_clock :: NOW())
{} 〜scoped_timer(){
high_resolution_clock :: time_point停止= high_resolution_clock ::现在();
常量双T = 1E-9 * duration_cast<&纳秒GT;(停_start).Count之间的();
性病::法院LT&;< (
提高::格式(
%1%:%| 2 $ -5.3g |%| 3 $ | / S(%| $ 4 -5.3g | S)
)%_what%(_how_many /吨)%_units%叔
)LT;<的std :: ENDL;
}私人的: 常量标准::字符串_what;
常量标准::字符串_units;
const的双_how_many;
常量high_resolution_clock :: time_point _start;
};#万一
解决方案有关时辰在Eclipse中你应该添加这些符号
_GLIBCXX_USE_C99_STDINT_TR1
和
__ CPLUSPLUS = 201103L
如何添加它们:
Prject属性 - > C / C ++常规 - >路径和符号 - >符号(标签) - > GNU C ++ - >还有点击添加
记住要添加
__ CPLUSPLUS
值为201103L
I use some code to report duration of a task using std::chrono::high_resolution_clock ... part of c++0x.
I can successfully compile c++0x features in eclipse cdt using the -gnu++0x flag. Although successfully compiling, the editor seemed unaware of c++0x i.e. it displayed errors for any c++0x features in my code. I solved that by adding the -gnu++0x flag to my project discovery options. Note: doesn't show fixed until you do another compile and rebuild the index ...
-E -P -v -dD "${plugin_state_location}/specs.cpp" -std=gnu++0x
I still have one last editor error that I can't rid myself of "Symbol 'duration_cast' could not be resolved" (I had a pic but new users can't post pics)
Anyone have any ideas on how to fix this? Here is the code:
#ifndef _scoped_timer_h_ #define _scoped_timer_h_ #include <iostream> #include <chrono> #include "boost/noncopyable.hpp" #include "boost/format.hpp" using namespace std::chrono; // Utility class for timing and logging rates // (ie "things-per-second"). // NB _any_ destructor invokation (including early return // from a function or exception throw) will trigger an // output which will assume that whatever is being measured // has completed successfully and fully. class scoped_timer : boost::noncopyable { public: scoped_timer( const std::string& what, const std::string& units, double n ) :_what(what) ,_units(units) ,_how_many(n) ,_start(high_resolution_clock::now()) {} ~scoped_timer() { high_resolution_clock::time_point stop = high_resolution_clock::now(); const double t = 1e-9 * duration_cast<nanoseconds>(stop-_start).count(); std::cout << ( boost::format( "%1%: %|2$-5.3g| %|3$|/s (%|4$-5.3g|s)" ) % _what % (_how_many/t) % _units % t ) << std::endl; } private: const std::string _what; const std::string _units; const double _how_many; const high_resolution_clock::time_point _start; }; #endif
解决方案For chrono in eclipse you should add those symbols
_GLIBCXX_USE_C99_STDINT_TR1
and
__cplusplus = 201103L
How to add them:
Prject properties -> C/C++ General -> Path and Symbols -> Symbols (Tab) -> GNU C++ -> and there click add.
Remember to add
__cplusplus
with value201103L
这篇关于的C ++ 0x编译但即使-gnu Eclipse编辑器错误++ 0x中发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!