Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C : Can't parse function after macro line #191

Closed
blackb1rd opened this issue Dec 21, 2014 · 8 comments
Closed

C : Can't parse function after macro line #191

blackb1rd opened this issue Dec 21, 2014 · 8 comments
Milestone

Comments

@blackb1rd
Copy link

Hello,
I found a bug in parsing C using ctags (it's in exuberant-ctags also).

The problem is the following:

#include <stdio.h>

#define PRAGMA(x) _Pragma(#x)
PRAGMA(bar)
int foo() {
    int a = 1;
    printf("a = %d\n", a);
}

void main(void) {
    foo();
}

Output of ctags file did not have a function foo() as below.

PRAGMA  f.c /^#define PRAGMA(/;"    d   file:
PRAGMA  f.c /^PRAGMA(bar)$/;"   f
main    f.c /^void main(void) {$/;" f

Thanks!!

@masatake
Copy link
Member

Thank you for reporting.
Important but fixing this is not easy.

@masatake masatake added this to the Feature plan milestone Dec 25, 2014
@masatake
Copy link
Member

Private note: We have to record the macro definition in directiveDefine of get.c
cork layer I'm working in a branch can be used. Input stream must be hacked.
I have to check geany's memory based input stream.

@blueyed
Copy link
Contributor

blueyed commented Feb 1, 2015

@masatake
Have you made progress on this?
Is your branch available somewhere?

@masatake
Copy link
Member

masatake commented Feb 2, 2015

No. I do nothing about this topic.

@ntrel
Copy link
Contributor

ntrel commented Feb 2, 2015

Perhaps you could use ctags -I 'PRAGMA+' to skip the macro expansion part.

@b4n
Copy link
Member

b4n commented Feb 2, 2015

Private note: We have to record the macro definition in directiveDefine of get.c cork layer

This will not be enough to solve all macro usage, because many can come from included headers, and expand to weird things, so without a full-blown C preprocessor it won't ever be perfect. So I wonder if it makes sense to add all the complexity required to track macro expansion if it won't ever be enough.

@masatake
Copy link
Member

masatake commented Feb 3, 2015

@b4n, I agree.

@blackb1rd blackb1rd changed the title C : Can't parsing function after macro line C : Can't parse function after macro line Jul 5, 2015
@masatake
Copy link
Member

I don't know the trick but the new parse solves this.
I got:

PRAGMA  /tmp/enum.c /^#define PRAGMA(/;"    d   file:
foo /tmp/enum.c /^int foo() {$/;"   f
main    /tmp/enum.c /^void main(void) {$/;" f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants