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

Parse C/C++ tags wrapped in an extern "C" {...} block #349

Closed
ntrel opened this issue Oct 7, 2014 · 14 comments
Closed

Parse C/C++ tags wrapped in an extern "C" {...} block #349

ntrel opened this issue Oct 7, 2014 · 14 comments

Comments

@ntrel
Copy link
Member

ntrel commented Oct 7, 2014

Geany fails to parse tags wrapped in an extern "C" {...} block, even in C++. The construct should be recognised for the C parser also, so this pattern is supported:

#ifdef __cplusplus
extern "C"
{
#endif

extern int i; // should be parsed as a global

#ifdef __cplusplus
}
#endif
@elextr
Copy link
Member

elextr commented Oct 7, 2014

Agree, although inside {} these are really global declarations.

@ntrel
Copy link
Member Author

ntrel commented Oct 9, 2014

@elextr Yep, added extern.

@ntrel
Copy link
Member Author

ntrel commented Oct 31, 2014

BTW fishman ctags does parse extern C blocks, and our code is probably meant to (e.g. isExternCDecl). I tried to investigate but couldn't find the problem, the parsers are a bit too divergent.

@b4n
Copy link
Member

b4n commented Nov 9, 2014

Err, what are you using? For me it works just fine, and produces an Extern Variables i tag for line 6, just as expected.

@codebrainz
Copy link
Member

I'm having this issue too, on Windows 10, types are not highlighted correctly inside extern "C" blocks (whether guarded or not). For example,

#ifdef __cplusplus
extern "C" {
#endif
typedef struct SomeStruct SomeTypedef;
struct SomeStruct
{
    int x;
};
#ifdef __cplusplus
}
#endif

Doesn't highlight the type name "SomeTypedef" in C, but it does for the "SomeStruct". If I switch the filetype to C++, neither type is highlighted.

It must be Windows-specific, I know this works fine Linux for sure.

@elextr
Copy link
Member

elextr commented Dec 10, 2015

Confirm that like @b4n the test code used by @codebrainz works fine on linux.

@codebrainz
Copy link
Member

As a workaround, putting the extern "C" { in a separate header a la G_BEGIN_DECLS fixes tag parsing inside the block.

@eht16
Copy link
Member

eht16 commented Jun 25, 2017

Just for the record, I tested the code snippet on Windows with the ctags binary we ship with Geany-Plugins (originating from the MSYS2 ctags package) and this binary also does not parse the extern variable.
Still no clue what could cause the different behaviour in parsing on Windows :(.

@masatake
Copy link
Contributor

As far as trying the input directly with u-ctags, it captures all expected tags.

@techee
Copy link
Member

techee commented Dec 22, 2021

@eht16 Did the new cxx parser fix this issue on Windows?

@eht16
Copy link
Member

eht16 commented Jan 2, 2022

It does!
geany_windows_externc

I guess we can close this now.

@techee
Copy link
Member

techee commented Jan 2, 2022

Good, one more mysterious bug away.

@techee techee closed this as completed Jan 2, 2022
@kugel-
Copy link
Member

kugel- commented Jan 2, 2022

Maybe have a unit test for this?

@techee
Copy link
Member

techee commented Jan 6, 2022

Maybe have a unit test for this?

Yeah, but parser problems should mostly be business of uctags now. And I think the new cxx parser is tested quite well there.

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

No branches or pull requests

8 participants