CScout version 2.8 offers a command-line option (-C) that will create a vim-compatible tags file for the C source code it will process. CScout is a source code analyzer and refactoring browser for collections of C programs. It can process workspaces of multiple projects mapping the complexity introduced by the C preprocessor back into the original C source code files. Consequently, the generated tags file contains correct information for entities, like functions, variables, and structures, that are created through preprocessor macros. CScout will process include files, using the include file paths specified in the code's project configuration file (the equivalent of a Makefile). To try it out, download the package matching your setup, go into the example directory containing the awk source code and run
../bin/cscout -Cc awk.cs
You can see some types of preprocessor constructs that CScout can handle in this page. For example, if you process the following code
#define typefun(name, type, op) \
type type ## _ ## name(type a, type b) { return a op b; }
typefun(add, int, +)
typefun(sub, int, -)
typefun(mul, int, *)
typefun(div, int, /)
typefun(add, double, +)
typefun(sub, double, -)
typefun(mul, double, *)
typefun(div, double, /)
main()
{
printf("%d\n", int_add(5, 4));
printf("%g\n", double_mul(3.14, 2.0));
}
CScout will generate a tags file with the following entries.
double_add test.c 8 ;" f
double_div test.c 11 ;" f
double_mul test.c 10 ;" f
double_sub test.c 9 ;" f
int_add test.c 4 ;" f
int_div test.c 7 ;" f
int_mul test.c 6 ;" f
int_sub test.c 5 ;" f
main test.c 13 ;" f
typefun test.c 1 ;" d
You can try it out yourself by adding a few code-generating macros in the example source code to see the tags CScout will create.