Reputation: 43
I've used both cscope and exuberant-ctags with VIM with great results on pure C projects. However, I've now moved on to a large mixed C / C++ / Java project with a lot of crufty old code and I'm trying to use cscope to gain insight into the code flow. I'm having trouble getting cscope to recognize some functions that reside in a C++ file.
For example, in this particular project, there is a C function named "verifySignature" that's defined as global. There's a different function also named "verifySignature" that's defined as a static function within a .cpp file.
When I use <ctrl-]> or <g]> in VIM, or when I use standalone cscope to find the definition, it invariably takes me to the C function even when VIM is editing the file where the static C++ function is defined (this led to profound confusion before I realized that there were two 'verifySignature' functions and I was looking at the wrong one).
When I use cscope to find functions that call 'verifySignature', it only lists the invocations of the C function. It's as if cscope is unaware of the C++ function.
However, when I use <ctrl-\ s>, or when I use standalone cscope to find the symbol, it lists both functions as well as every place where either function is called.
So it -does- know about the C++ function, it just doesn't always show it.
As another data point, I renamed the C++ function to 'verifySignature2' so that its name is unique across the codebase leaving everything else unchanged (still static, etc), rebuilt my cscope/ctags databases and searched again. This time, <ctrl-]> in VIM and 'find global definition' had no trouble finding the C++ routine.
Based on this, I'd almost be inclined to say that cscope ignores static symbols if there's a global symbol with the same name. Except I have anecdotal evidence from pure 'C' projects that that's not true. So I'm scratching my head...
I'm generating the cross reference files using the following commands:
> find . -regextype posix-extended -regex '.*\.(c|C|cpp|h|hpp|s|S|java)' > cscope.files
> usr/bin/cscope -b -q -f cscope.out
> /usr/bin/ctags --c++-kinds=+p --fields=+iaS --extra=+q -L cscope.files
Am I doing something wrong?
Upvotes: 2
Views: 645
Reputation: 28366
YouCompleteMe would also help you write code, beside navigating it with its GoTo*
commands, and showing type/function/whatever signatures in a pop-up menu. You might also want to give a look at tagbar.
Upvotes: 0