Bug 327902

Summary: CPP parser does not recognize offsetof
Product: [Applications] kdevelop Reporter: ChrisiPK
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal CC: craftplace.ms
Priority: NOR    
Version First Reported In: 4.5.2   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Minimal test case

Description ChrisiPK 2013-11-21 14:15:09 UTC
Actual behavior:
When using the offsetof macro, Kdevelop creates a yellow underline under the macro and the member name (2nd parameter). The text given in the hover popup is: "Problem in Semantic Analysis: Declaration not found: offsetof" (translated from German, might not be the actual English text).

Expected behavior:
Kdevelop should be able to find the declaration of offsetof.
Comment 1 Kevin Funk 2013-11-21 14:26:17 UTC
Did you include stddef.h?

There's support for __builtin_offset(TYPE, MEMBER) in KDevelop, which offsetof is defined to.

Works for me. No problems reported.
Comment 2 ChrisiPK 2013-11-21 14:37:16 UTC
I tried including both <stddef.h> and <cstddef>, no success. What else could be the problem? How can I provide more info so you can reproduce?
Comment 3 ChrisiPK 2013-11-21 17:03:08 UTC
Created attachment 83684 [details]
Minimal test case

This is a minimal test case where the problem occurs for me. Please let me know whether this works for you.
Comment 4 Kevin Funk 2013-11-21 18:17:44 UTC
Hm indeed. There's something odd going on:

In case you didn't open stddef.h in a separate tap, offsetof will not be recognized.
As soon as you open that file, and then press F5 in the file using offsetof, the macro will be parsed correctly.

Milian, ideas?
Comment 5 Andrey Cygankov 2016-01-23 22:59:17 UTC
I tried to reproduce the bug, all displayed without problems.
http://i.imgur.com/OmqDsBP.png
Probably it is necessary to close.
Comment 6 ChrisiPK 2016-01-23 23:39:27 UTC
Might be that this is fixed in 4.7. I am currently running 4.6.0 and the problem still exists here.

http://i.imgur.com/LivId1x.png
Comment 7 Andrey Cygankov 2016-01-23 23:50:25 UTC
Yes, I forgot to specify - tested in KDevelop 5.
Comment 8 Milian Wolff 2016-01-24 12:16:46 UTC
Hello!

We are working on a new clang-based C/C++ language plugin for KDevelop 5 which
supersedes the old C++ plugin in KDevelop 4. See e.g.:
https://www.kdevelop.org/news/first-beta-release-kdevelop-500-available

Due to a lack of manpower, we cannot fix bugs in the old C++ plugin. We rather
want to supply a good Clang based C++ experience for KDevelop 5 than wasting
our time on the legacy C++ support for KDevelop 4.

With the new clang-based C/C++ language plugin, the bug presented here does not
occur. In my testing. For these reasons, I'll close this bug. Please stay tuned
for KDevelop 5.

If you think this bug is applicable to Clang/KDevelop 5, please reopen the
report and add new information on how to reproduce the bug there.

Sorry for the inconvenience, I hope you understand the reasoning above.

Cheers