top of page
  • Zach Pfeffer

Generate Ctags Files for C/C++ Source Files


Post Description

This post gives a summary of what each Exuberant Ctags flag means when generating more source code browsing info.

Generate Tags

-R says to look in all subdirectories.

The . matches all files.

Generate Tags with Expanded Info

This adds function prototypes (+p) which are normally off. It also includes inheritance information (i), access (or export) of class members (a) and signatures of routine (e.g. prototype or parameter list) (S) in the tags info field (so you can read it). Finally it ensures classes are qualified: class::member (+q).

Short Flags Explanation

Expanded Flags Explanation

−−<LANG>−kinds=[+|−]kinds

Specifies a list of language-specific kinds of tags (or kinds) to include in the output file for a particular language, where <LANG> is case-insensitive and is one of the built-in language names (see the −−list−languages option for a complete list). The parameter kinds is a group of one-letter flags designating kinds of tags (particular to the language) to either include or exclude from the output. The specific sets of flags recognized for each language, their meanings and defaults may be list using the −−list−kinds option. Each letter or group of letters may be preceded by either ’+’ to add it to, or ’−’ to remove it from, the default set. In the absence of any preceding ’+’ or ’−’ sign, only those kinds explicitly listed in kinds will be included in the output (i.e. overriding the default for the specified language).

As an example for the C language, in order to add prototypes and external variable declarations to the default set of tag kinds, but exclude macros, use −−c−kinds=+px−d; to include only tags for functions, use −−c−kinds=f.

Output of 'ctags --list-languages':

−−fields=[+|−]flags

Specifies the available extension fields which are to be included in the entries of the tag file (see TAG FILE FORMAT, below, for more information). The parameter flags is a set of one-letter flags, each representing one type of extension field to include, with the following meanings (disabled by default unless indicated):

a - Access (or export) of class members

f - File-restricted scoping [enabled]

i - Inheritance information

k - Kind of tag as a single letter [enabled]

K - Kind of tag as full name

l - Language of source file containing tag

m - Implementation information

n - Line number of tag definition

s - Scope of tag definition [enabled]

S - Signature of routine (e.g. prototype or parameter list)

z - Include the "kind:" key in kind field

t - Type and name of a variable or typedef as "typeref:" field [enabled]

Each letter or group of letters may be preceded by either ’+’ to add it to the default set, or ’−’ to exclude it. In the absence of any preceding ’+’ or ’−’ sign, only those kinds explicitly listed in flags will be included in the output (i.e. overriding the default set). This option is ignored if the option −−format=1 has been specified. The default value of this option is fkst.

−−extra=[+|−]flags

Specifies whether to include extra tag entries for certain kinds of information. The parameter flags is a set of one-letter flags, each representing one kind of extra tag entry to include in the tag file. If flags is preceded by by either the ’+’ or ’−’ character, the effect of each flag is added to, or removed from, those currently enabled; otherwise the flags replace any current settings. The meaning of each flag is as follows:

f - Include an entry for the base file name of every source file (e.g. "example.c"), which addresses the first line of the file.

q - Include an extra class-qualified tag entry for each tag which is a member of a class (for languages for which this information is extracted; currently C++, Eiffel, and Java). The actual form of the qualified tag depends upon the language from which the tag was derived (using a form that is most natural for how qualified calls are specified in the language). For C++, it is in the form "class::member"; for Eiffel and Java, it is in the form "class.member". This may allow easier location of a specific tags when multiple occurrences of a tag name occur in the tag file. Note, however, that this could potentially more than double the size of the tag file.

Version Detail

References

  • Find how to generate ctags with more symbols by Hong (@xuhdev)

  • Escape <> in pre tags @ link.

  • Documentation for Exhuberate Tags @ link.

  • Cat poster from Amazon.com. Click here to buy.

bottom of page