I use ctags
to generate the tags
file for the C project I'm working on, but many functions are missing from the file. This is apparently caused by unbalanced curly braces in the source files due to the use of #ifdef
. A (simplified):
#include <stdio.h> struct mystruct { long member; #ifndef _MSC_VER }__attribute__ ((packed)); #else /* _MSC_VER */ }; #pragma pack(pop) #endif /* _MSC_VER */ char* greeting_text(){ return "Hello world\n"; } int main( int argc, const char* argv[] ){ char * greeting = greeting_text(); printf(greeting); return 0; }
This compiles and works flawlessly with gcc -Wall
under Linux. However, if I analyze it using ctags problem.c
, the tags
file contains only entries for mystruct
- there are no functions.
ctags --verbose
reports:
OPENING problem.c as C language file problem.c: unexpected closing brace at line 8 problem.c: retrying file with fallback brace matching algorithm OPENING problem.c as C language file problem.c: unexpected closing brace at line 8
therefore, obviously, ctags
does not like preprocessor tricks in a file.
Is there a way to make ctags
handle this?
The manpage ctags
even explicitly mentions this problem, but indicates that ctags
can get around this. However, this does not work ...
This is with Exuberant Ctags 5.8 (Debian package 1: 5.8-4).
Edit:
I am also interested in alternatives to ctags that handle these types of constructs.
source share