Eclipse CDT Indigo CLOCKS_PER_SEC could not be resolved issue

青春壹個敷衍的年華 提交于 2019-12-23 12:23:24

问题


I dont know if this is a bug or i am the only one facing this,

In Eclipse CDT indigo, create a new C++ executable project and create a CPP file in a C++ source folder.i.e. src/test.cpp

#include<iostream>
#include<ctime>
using namespace std;
int main()
{
    clock_t strt = clock();
    int i = 2;
    clock_t end = clock();
    cout<<(end-strt)*1000.0f/CLOCKS_PER_SEC;
    return 0;
}

now see that the CLOCKS_PER_SEC is unresolved, but project compiles sucessfully and runs fine too. I am on ubuntu 10.10 64 bit. Is this a bug or some settings screw up ( indexer? ) ?


回答1:


You can manually add the time.h to the indexer, go to Preferences -> C/C++ -> Indexer and put it in front of the existing "Files to be indexed up-front" like this:

time.h, cstdarg, ...

Then it should work just fine.




回答2:


This is a known bug in CDT: https://bugs.eclipse.org/bugs/show_bug.cgi?id=351549. It might have been fixed in the nightly build.




回答3:


My eclipse behaves exact the same way. I think it's something about indexer.




回答4:


comment no.17 on this bug report worked for me

Project->Properties->Indexer: "Files to index up-front" Put ctime at the beginning of the list.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=351549



来源:https://stackoverflow.com/questions/7476373/eclipse-cdt-indigo-clocks-per-sec-could-not-be-resolved-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!