I am working on a very large project which uses the usually not so elegant but useful C macro stringification tricks to generate dynamic symbol names such as:
#define FUNCTION_NAME(signal) (void Callback_ ## signal ## (void))
I use ctags with vim, or visual studio code or eclipse. But there seems to be no way to be able to browse names generated during the preprocessing stage, and i understand why. But as large as the project is, is there a way to plug ctags into the build process so that it can build an index while the build happens. Or any other way of getting around this problem.
Universal Ctags has the ability to expand macro defined in the command line. -D
option can be used for this purpose.
$ cat -n /tmp/input.c
1 FUNCTION_NAME(term)
2 {
3 /* Do something */
4 }
5
6 FUNCTION_NAME(hup)
7 {
8 /* Do something */
9 }
10
11
$ ~/bin/ctags -D 'FUNCTION_NAME(signal)=void Callback_ ## signal ## (void)' -o - /tmp/input.c
Callback_hup /tmp/input.c /^FUNCTION_NAME(hup)$/;" f typeref:typename:void
Callback_term /tmp/input.c /^FUNCTION_NAME(term)$/;" f typeref:typename:void
See also https://docs.ctags.io/en/latest/man/ctags.1.html#language-specific-options