|
From: | Shigio YAMAGUCHI |
Subject: | Re: gtags fail to index C++ exported class |
Date: | Mon, 17 Nov 2014 11:33:44 +0900 |
Hello,
I'm using Global on some cross-platform C++ code, and I have an issue with exported class such as :
class FOO_API Foo
{
//blablalba
};
Where FOO_API is a compiler specific #define that affect symbol visibility, or binding conventions.
The problem here is that gtags expect the class name to follow the "class" keyword, and fail to index those class properly (and exported class are often important ones !)
I couldn't find any workaround to solve this issue, and I'm note alone : it was already reported a few years ago by Ashish : http://lists.gnu.org/archive/html/bug-global/2011-05/msg00000.htm
Looking at the code, I found an easy way to fix it. Not sure if it's the best way to go, but at least "It works on my machine" ;)
In libparser/Cpp.c, patch void Cpp(const struct parser_param *param) this way :
case CPP_CLASS:
DBG_PRINT(level, "class");
if ((c = nexttoken(interested, cpp_reserved_word)) == SYMBOL) {
/*beginning of patch : skip predifined API directives*/
if(is_api_directive(token))
if ((c = nexttoken(interested, cpp_reserved_word)) != SYMBOL)
break;
/*end of patch*/
strlimcpy(classname, token, sizeof(classname));
/*
* Ignore forward definitions.
* "class name;"
*/
if (peekc(0) != ';') {
startclass = 1;
PUT(PARSER_DEF, token, lineno, sp);
}
}
break;
Where is_api_directive might be defined in the same file this way :
static int is_api_directive(const char* token)
{
int res=0;
if(token!=NULL && api_directive_list!=NULL)
if(strstr(api_directive_list, token)!=NULL)
res=1;
return res;
}
It relies on api_directive_list, which is a global char array, populated from command line, with something like "EXPORT_FOO_API:EXPORT_BAR_API:EXPORT_BAZ_API".
Hope this helps,
Julien
_______________________________________________
Bug-global mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-global
[Prev in Thread] | Current Thread | [Next in Thread] |