Posted on 2008-05-18 21:20
闻太师 阅读(3064)
评论(0) 编辑 收藏 引用 所属分类:
vim
代码:Tlist 出来的结果,发现有些函数没有显示,只在百度搜到一个相关帖子。那哥们在帖子中写道:
“我又试了几个类似的,貎似不能生成函数声明的tag,这也会影响到C-X C-O的补全效果。 通读了一遍ctags的document,搞定,看来以后还是应该少问多看。”
之后竟无后话,bs之。尝试观摩ctags的manual,无奈E文残障人士,难解其意。
尝试改变几次代码的格式,竟让我找到答案:ctags对#ifndef #else #endif的结构解析有问题,会影响其后的函数解析,将其中的#else注释掉,update一下Tlist,重新生成一下标签文件即可满足阅读需要。
再返过来看看ctags的manual,竟然找到对应的段子如下:
This implementation of ctags imposes no formatting requirements on C code as do legacy implementations. Older implementations of ctags tended to rely upon certain formatting assumptions in order to help it resolve coding dilemmas caused by preprocessor conditionals.
In general, ctags tries to be smart about conditional preprocessor directives. If a preprocessor conditional is encountered within a statement which defines a tag, ctags follows only the first branch of that conditional (except in the special case of "#if 0", in which case it follows only the last branch). The reason for this is that failing to pursue only one branch can result in ambiguous syntax, as in the following example:
|
#ifdef TWO_ALTERNATIVES struct { #else union { #endif
|
|
Both branches cannot be followed, or braces become unbalanced and ctags would be unable to make sense of the syntax.
|
Sigh~How pool My English!
附 生成标签文件参数:
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q src
在对C++文件进行补全时,OmniCppComplete插件需要在标签文件中包含C++的额外信息,因此上面的ctags命令不同于以前我们所使用的,它专门为C++语言生成一些额外的信息,上述选项的含义如下:
--c++-kinds=+p : 为C++文件增加函数原型的标签
--fields=+iaS : 在标签文件中加入继承信息(i)、类成员的访问控制信息(a)、以及函数的指纹(S)
--extra=+q : 为标签增加类修饰符。注意,如果没有此选项,将不能对类成员补全