user1641774
user1641774

Reputation:

ctags not getting functions whose return value types are above the function names

I am working with some code which has the following style:

int
add5 (int x) {
    return x+5;
}

In other words, the return value type of the function is written right above the function's name. Because of that, ctags is not recognizing these functions and causing me a terrible headache. Does someone know how to get ctags to handle this case?

EDIT: ctags can recognize the function names on .c files but what I need is ctags to recognize the function names on .h files. On the .h files I have things such as:

int
add5 (int);

and there ctags does not recognize add5.

Upvotes: 0

Views: 999

Answers (2)

Jack
Jack

Reputation: 1606

It sounds to me like ctags is recognizing the function but not finding its declaration.

In fact, if you create this function in a header file:

int
plus(int a,int b) {
    return a+b;
}

ctags can find it.

Upvotes: 0

Birei
Birei

Reputation: 36272

You have to tell ctags to search for prototypes of functions. It is done with --<LANG>-kinds option.

So, run following command:

ctags --c-kinds=+p *

And it will add the declaration to the tags file, as you can see in the output of my test:

!_TAG_FILE_FORMAT       2       /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /[email protected]/
!_TAG_PROGRAM_NAME      Exuberant Ctags //
!_TAG_PROGRAM_URL       http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION   5.8     //
add5    add.h   /^add5 (int);$/;"       p

Upvotes: 2

Related Questions