Open mtozjh opened 4 years ago
C parser is completely rewritten in u-ctags. Please, use -D option as shown below.
$ cat /tmp/foo.c
void FTNC(etmif_set_argv)(double *value, int *i)
{
ETMIF_argv[*i] = *value;
return;
}
$ ./ctags -o - -D'FTNC(n)=n' /tmp/foo.c
etmif_set_argv /tmp/foo.c /^void FTNC(etmif_set_argv)(double *value, int *i)$/;" f language:C typeref:typename:void
Thanks for the quick response. I know this workaround. Actually I am looking for the behavior like Exuberant Ctas 5.8. Since there are thousands of C/CPP files, it is heavy burden for user to work around all MACRO like this.
will you deliver an enhancement?
will you deliver an enhancement?
Yes, but I will take more than 1 year to implement it.
ctags itself knows the definitions of macro.
$ cat /tmp/foo.h
#define FTNC(f) f
$./ctags -o - --fields-C++=+'{macrodef}' /tmp/foo.h
FTNC /tmp/foo.h /^#define FTNC(/;" d language:C++ macrodef:f
So ctags can prepare the arugments for -D option by itself.
I had a prototype and it worked.
However, what I have to do is written in https://github.com/universal-ctags/ctags/issues/1038 .
Look forward to that release.
BTY, this is really a great tool.
We added so many features, so I cannot remember them timely.
If it is acceptable to run ctags twice, you don't have to specify -D option manually.
$ cat /tmp/foo.h
#define FTNC(f) f
#define BODY(x) { return (x); }
#define R(B) int B
R(FTNC(func)(FTCN(int i))BODY(x))
$ ./ctags -o /tmp/foo.ctags --fields-C++=+'{macrodef}' --fields=+S -x --_xformat="-D%{name}%{signature}=%{C++.macrodef}" /tmp/foo.h
$ ./ctags -o - --options=/tmp/foo.ctags /tmp/foo.h
BODY /tmp/foo.h /^#define BODY(/;" d language:C++
FTNC /tmp/foo.h /^#define FTNC(/;" d language:C++
R /tmp/foo.h /^#define R(/;" d language:C++
func /tmp/foo.h /^R(FTNC(func)(FTCN(int i))BODY(x))$/;" f language:C++ typeref:typename:int
@pragmaware, you may be interested in this output. I'm surprised at this works well.
./ctags -o - --languages=+OldC --language-force=OldC ...
runs old C parser inherited from Exuberant Ctags. (But we will not fix the bug for it even if we got a bug report.)
See https://github.com/universal-ctags/ctags/pull/2427. If a macro is defined in the same input file and ifdefs are not used aggressively, macros can be expanded automatically.
( Thank you for contacting us.
If you are reporting an issue with the parsing output, please fill the following template. As your custom CTags configuration can affect results, please always use
--options=NONE
as the first option when runningctags
.Otherwise, delete the template and write your issue from scratch. Examples may help developers understanding your issue better.
Use GitHub web interface and markdown notation. Using mail results broken text rendering that makes the developers go crazy. )
The name of the parser: c/c++
The command line you used to run ctags:
The content of input file:
FTNC /u/yanchen/.FAST_9995.src.c 6562;" kind:f line:6562 language:C typeref:typename:void signature:(etmif_set_argv) end:6666
The tags output you expect:
The version of ctags: