C ++源代码标记 [英] C++ source tagging

查看:85
本文介绍了C ++源代码标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关标记和搜索c ++代码的优质方法的任何建议。我将cscope / ctags用于大多数内容,但发现在工作中某些过于复杂的c ++代码中找不到自己的方式是不够的。我已经开始从vim切换到Slickedit(仍然不完美,但是更好)来浏览代码,但是我想回到专有的vim。

Any suggestions on a quality way to tag and search c++ code. I use cscope/ctags for most stuff, but I have found it insufficient to find my way around some of the overly complex c++ code at work. I have started to switch from vim to Slickedit (which is still not perfect, but better) for browsing code, but would like to go back to exclusively vim.

我想要的是可以理解类成员范围的东西,例如,如果我搜索对存在相同成员名称的类成员的引用,在其他类中(可能不在c ++代码中),它只会给我相关的参考。

What I would like is something that can understand scope of class members so, for instance, if I search for references to a member of a class where the same member name exists in other classes (and possibly out of c++ code) it will only give me the relevant references.

我希望已经可以在vim上正常工作的东西,但是任何可以自己创建插件的开源软件包都可以。

I'd prefer something that already works nice with vim, but any open source package such that I might create a plugin myself would be fine.

任何建议,谢谢。

推荐答案

您确定吗?正确的选项叫ctags?对于C ++,我使用:

Are you sure you called ctags with the right options? For C++, I use:

ctags --c ++-kinds = + p --fields = + iaS --extra = + q- language-force = C ++

这是文档关于-c ++-kinds = +所说的内容p 选项:


在解析C ++成员函数定义时(例如
className :: function ),则ctags无法确定范围说明符
是类名还是名称空间说明符,并且始终在扩展字段的范围部分将其列为类名
。此外,如果在类声明之外定义了C ++
函数(通常情况),则
访问规范(即公共,受保护或私有)和
实现信息(例如虚拟,为函数
定义生成标记时,不知道函数
声明中包含的纯虚拟)。但是它将适用于原型

(例如--c ++-kinds = + p)。

When parsing a C++ member function definition (e.g. "className::function"), ctags cannot determine whether the scope specifier is a class name or a namespace specifier and always lists it as a class name in the scope portion of the extension fields. Also, if a C++ function is defined outside of the class declaration (the usual case), the access specification (i.e. public, protected, or private) and implementation information (e.g. virtual, pure virtual) contained in the function declaration are not known when the tag is generated for the function definition. It will, however be available for prototypes
(e.g --c++-kinds=+p).

-fields = + iaS 选项:

 a   Access (or export) of class members
 i   Inheritance information
 S   Signature of routine (e.g. prototype or parameter list)

-extra = + q 选项:


因为,默认情况下,ctags仅为源文件中找到的单独标识符生成标签。如果您指定--extra = + q选项,则ctags还将为类的每个类成员(数据和函数/方法)以C:++的形式生成
的类限定的第二个
标记,并且格式为Eiffel和Java。

Because, by default, ctags only generates tags for the separate identifiers found in the source files. If you specify the --extra=+q option, then ctags will also generate a second, class-qualified tag for each class member (data and function/method) in the form class::member for C++, and in the form class.method for Eiffel and Java.

-language-force = C ++ 选项:

默认情况下,ctags自动选择源文件的语言,而忽略那些无法确定其语言的文件(请参见上文的源文件)。此选项强制为每个提供的文件使用指定的语言(不区分大小写;内置或用户定义的语言),而不是根据扩展名自动选择语言。此外,特殊值auto表示应自动选择语言(实际上会禁用此选项)。

By default, ctags automatically selects the language of a source file, ignoring those files whose language cannot be determined (see SOURCE FILES, above). This option forces the specified language (case-insensitive; either built-in or user-defined) to be used for every supplied file instead of automatically selecting the language based upon its extension. In addition, the special value auto indicates that the language should be automatically selected (which effectively disables this option).

这篇关于C ++源代码标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆