[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gtags fail to index C++ exported class
From: |
Julien Montmartin |
Subject: |
gtags fail to index C++ exported class |
Date: |
Sun, 16 Nov 2014 15:05:50 +0100 |
User-agent: |
Postbox 3.0.11 (Macintosh/20140602) |
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
- gtags fail to index C++ exported class,
Julien Montmartin <=
- Re: gtags fail to index C++ exported class, Shigio YAMAGUCHI, 2014/11/16
- Re: gtags fail to index C++ exported class, Jason Hood, 2014/11/18
- Message not available
- Re: gtags fail to index C++ exported class, Jason Hood, 2014/11/18
- Re: gtags fail to index C++ exported class, Shigio YAMAGUCHI, 2014/11/19
- Re: gtags fail to index C++ exported class, Jason Hood, 2014/11/19
- Re: gtags fail to index C++ exported class, Shigio YAMAGUCHI, 2014/11/19
- Re: gtags fail to index C++ exported class, Julien Montmartin, 2014/11/19
- Re: gtags fail to index C++ exported class, Shigio YAMAGUCHI, 2014/11/25
- Re: gtags fail to index C++ exported class, Jason Hood, 2014/11/27
- Re: gtags fail to index C++ exported class, Shigio YAMAGUCHI, 2014/11/27