How to find this global definition with cscope when there are two functions which had the same name at different file?

StackOverflow https://stackoverflow.com/questions/16580803

  •  29-05-2022
  •  | 
  •  

Question

I read the code of redis with vim and build the database like this:

find . -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' > cscope.files
cscope -bq -i cscope.files -f cscope.out

and map keys in vim:

nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR>

When I read src/dict.c and want to find the definition of function _dictInit, it should locate to the definition at src/dict.c, but actually it locate to the definition at deps/hiredis/dict.c, which has the same name function definition

So how should I fix the problem?

Was it helpful?

Solution

That occurrence of _dictInit in deps/hiredis/dict.c is the first entry in the database.

Since there are two entries you should get a list like this one:

cscope result

that allows you to choose which definition to jump to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top