Bug 237388 - C++ parser doesn't correctly parse time.h
Summary: C++ parser doesn't correctly parse time.h
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (other bugs)
Version First Reported In: 4.0.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 15:49 UTC by Gerhard
Modified: 2018-11-16 09:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard 2010-05-12 15:49:49 UTC
Version:           4.0.0 (using KDE 4.4.3)
OS:                Linux
Installed from:    openSUSE RPMs

Consider following code snippet:

#include <iostream>
#include <iomanip>
#include <time.h>
 
using namespace std;

int main(int argc, char **argv)
{
    tm *p_tm;
    timespec current_time;
    
    clock_gettime(CLOCK_REALTIME, &current_time);

    p_tm = localtime(&current_time.tv_sec); 

   cout << "current time: " << setw(2) << p_tm->tm_hour << ":" << setw(2) << p_tm->tm_min << ":" << setw(2) << p_tm->tm_sec << endl;
}

The C++ parser complains it can't find the declarations of clock_gettime, CLOCK_REALTIME and localtime.

However, if I move the include of <time.h> to the first place, the example is correctly parsed.
Comment 1 Guido Winkelmann 2010-08-05 16:11:48 UTC
I can confirm this bug.

Also, the parser has similar problems with other types declared in time.h, for example time_t.
Comment 2 Nicolás Alvarez 2010-11-18 03:59:38 UTC
I didn't investigate yet, but I suspect this is the same problem as bug 237420.
Comment 3 Andrew Crouthamel 2018-11-05 03:14:35 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 4 Gerhard 2018-11-16 09:42:05 UTC
I just tested the code snippet above with kdevelop 5.3.0, and yes, it finally works :-)
Comment 5 Kevin Funk 2018-11-16 09:43:45 UTC
Thanks for the confirmation!