| Summary: | Parser cannot find std::time() function | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Nathan Ridge <zeratul976> | ||||||||
| Component: | cdt-indexer | Assignee: | Project Inbox <cdt-indexer-inbox> | ||||||||
| Status: | RESOLVED INVALID | QA Contact: | Markus Schorn <mschorn.eclipse> | ||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | cdtdoug, malaperle | ||||||||
| Version: | 8.0 | ||||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | All | ||||||||||
| OS: | Linux | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
I have the same problem with other standard <ctime> functions like gmtime, strftime, etc., as well as with standard <cstdio> functions like fopen, fclose, etc. Works for me. Have you tried reindexing? Right-click on project, Index, Rebuild. I'm on Ubuntu 10.10 with gcc 4.5. (In reply to comment #2) > Works for me. Have you tried reindexing? Right-click on project, Index, > Rebuild. I'm on Ubuntu 10.10 with gcc 4.5. I tried both Ubuntu 10.04 and Ubuntu 10.10 with gcc 4.5 and I get the error. Rebuilding the index doesn't help. However, I noticed that the error does not occur for the preprocessed source code, only the original with the #include directive. Which leads me to believe that either something is going wrong with the CDT parser's preprocessor, or the CDT parser and the gcc compiler somehow disagree on what the include paths are. Is there a way to see what the CDT parser thinks the preprocessed source code is, so that I can compare it to the actual preprocessed source code? (In reply to comment #3) You can create a parser-log to see if the include path + predefined macros passed to the indexer are reasonable (context menu of file in project explorer - Index - Create Parser Log). Chances are that the problem is related to bug 294180 Created attachment 185796 [details]
parser log
Attached is the parser log. It does not seem to include what the CDT parser thinks is the preprocessed version of the code.
Is there anything in there that gives a clue as to the cause of the problem?
I've reduced the test case to the slightly simpler:
#include <time.h>
int main()
{
time(0);
return 0;
}
and I've noticed something interesting: if I simply open up time.h (by doing Open Declaration on the include), and copy its contents and paste it in place of the include, the error goes away.
If I then go back to the original version with the include, the error comes back.
Reindexing does not change the situation in either case.
(In reply to comment #5) > Created an attachment (id=185796) [details] > parser log > Attached is the parser log. It does not seem to include what the CDT parser > thinks is the preprocessed version of the code. > Is there anything in there that gives a clue as to the cause of the problem? The parser-log suggests that your setup is ok. (In reply to comment #6) Please attach the version of 'time.h' you are using and provide the value of the indexer setting for files to parse up front (Project Properties - C/C++ General - Indexer). Created attachment 185847 [details]
The time.h that is being included
Attached is the time.h file that is being included. The local path was /usr/include/time.h
(In reply to comment #7) The indexer setting for files to parse up front is: stdarg.h, stddef.h, sys/types.h I tried adding time.h to this list but it made no difference. (In reply to comment #9) > (In reply to comment #7) > The indexer setting for files to parse up front is: > stdarg.h, stddef.h, sys/types.h > I tried adding time.h to this list but it made no difference. Please try to restore the defaults for the files to parse up front (the order is critical) and rebuild the index: cstdarg, stdarg.h, stddef.h, sys/resource.h, ctime, sys/types.h, signal.h, cstdio (In reply to comment #10) > (In reply to comment #9) > > (In reply to comment #7) > > The indexer setting for files to parse up front is: > > stdarg.h, stddef.h, sys/types.h > > I tried adding time.h to this list but it made no difference. > Please try to restore the defaults for the files to parse up front (the order > is critical) and rebuild the index: > cstdarg, stdarg.h, stddef.h, sys/resource.h, ctime, sys/types.h, signal.h, > cstdio That fixed the problem. I also realized how it came to be that my list of files to parse up front were not the default ones in spite of never having touched this option manually: In the Ganymede version of CDT, the list of files to parse up front was just stdarg.h, stddef.h, sys/types.h. Since then, every time I've upgraded to a new version of eclipse, I would export my preferences from the old version and import them into the new version (to preserve my syntax coloring scheme and so on), and the list of files to parse up from was among the preferences. You may want to mention this gotcha somewhere in the documentation/wiki. Thanks for your patience in helping me investigate this problem. I've marked the bug as resolved. |
Created attachment 184930 [details] preprocessed source file For this code: #include <ctime> int main() { std::time(0); return 0; } The parser gives the error: std::time : function could not be resolved I experience this issue on Ubuntu with gcc 4.4 or 4.5, but not on Windows with MinGW 4.5. I've attached the preprocessed source code (using the Ubuntu <ctime>).