Open reidakdumont opened 6 years ago
Though Vk and Vkey are not listed in your "The tags output you expect:", I guess what you expect are Vk and Vkey.
This behavior of ctags is expected and its limitation. Quoted from ctags.1 man page:
In general, ctags tries to be smart about conditional preprocessor directives. If a preprocessor con‐
ditional 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
short a;
long b;
}
Both branches cannot be followed, or braces become unbalanced and ctags would be unable to make sense
of the syntax.
Would it be possible to control which branch of conditional preprocessor directives is parsed with an option?
For example -D TWO_ALTERNATIVES
to undef and -D TWO_ALTERNATIVES=42
to change the value.
Otherwise I guess one option would be to use perl to comment/uncomment sections beforehand...
@pragmaware, how do you think this?
I would like to write my position. If someone (other than @pragmaware) implements the feature (extending cpreprocessor.c), I will not reject it. However, I will not implement the feature.
Running a perl or something preprocessor for ctags is very interesting idea. Generalizing it will make much benefits. However, that will be done after releasing 6.0.
The name of the parser: C++
The command line you used to run ctags:
The content of input file:
The tags output you are not satisfied with:
The tags output you expect:
The version of ctags:
How do you get ctags binary:
Building it locally, via GNU/Linux distribution, ubuntu 16.04