Ctags: C : 无法解析宏行后的函数

创建于 2014-12-21  ·  8评论  ·  资料来源: universal-ctags/ctags

你好,
我在使用 ctags 解析 C 时发现了一个错误(它也在 exuberant-ctags 中)。

问题如下:

#include <stdio.h>

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

void main(void) {
    foo();
}

ctags 文件的输出没有如下所示的foo()函数。

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

谢谢!!

Parser buenhancement

最有用的评论

我不知道诀窍,但新的解析解决了这个问题。
我有:

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

所有8条评论

感谢您的举报。
重要但解决这个问题并不容易。

私人注意:我们必须在get.c的directiveDefine中记录宏定义
软木层我在一个分支可以使用。 输入流必须被破解。
我必须检查 geany 基于内存的输入流。

@masatake
你在这方面取得了进展吗?
你的分行在某处可用吗?

不,我对这个话题没有做任何事情。

也许您可以使用ctags -I 'PRAGMA+'跳过宏扩展部分。

私人注意:我们要在get.c cork层的directiveDefine中记录宏定义

这不足以解决所有的宏使用问题,因为许多可能来自包含的头文件,并扩展到奇怪的东西,所以如果没有成熟的 C 预处理器,它永远不会是完美的。 所以我想知道如果它永远不够,添加跟踪宏扩展所需的所有复杂性是否有意义。

@b4n ,我同意。

我不知道诀窍,但新的解析解决了这个问题。
我有:

PRAGMA  /tmp/enum.c /^#define PRAGMA(/;"    d   file:
foo /tmp/enum.c /^int foo() {$/;"   f
main    /tmp/enum.c /^void main(void) {$/;" f
此页面是否有帮助?
0 / 5 - 0 等级

相关问题

blueyed picture blueyed  ·  4评论

trevordmiller picture trevordmiller  ·  9评论

cweagans picture cweagans  ·  8评论

lvc picture lvc  ·  3评论

fommil picture fommil  ·  19评论