Baroudi Safwen <[email protected]> wrote: > Le mardi 29 avril 2008 07:21:43 UTC+2, wiseker a écrit : >> In vim + cscope, we can use command ":cs find g name" to find the definition >> of a function or structure. But there are some problems for structures. >> >> For example, when we want to find the definition of struct device in linux >> kernel tree,the result is: >> # line filename / context / line >> 1 115 Documentation/lguest/lguest.c <<device>> >> struct device >> 2 32 Documentation/spi/spidev_test.c <<device>> >> static const char *device = "/dev/spidev1.1"; >> 3 117 arch/x86/kernel/early-quirks.c <<device>> >> u32 device; >> 4 48 arch/x86/kernel/reboot_fixups_32.c <<device>> >> unsigned int device; >> 5 46 arch/x86/pci/irq.c <<device>> >> u16 vendor, device; >> 6 53 arch/x86/pci/irq.c <<device>> >> int (*probe)(struct irq_router *r, struct pci_dev *router, u16 >> device);\ >> ...... >> >> That is because: 1) there are lots of "struct device" in header files (to >> avoid including headers); 2) Some locale variables with same name exists. >> >> How can we avoid this and find the right definition quickly? >> >> Thanks! > > I wrote a patch for vim that will sort the matches returned by cscope to put > the matches that end with '{' at the top. I work on the kernel and boy this > was useful. I'll be happy to share the patch if anyone is interested.
cscope and ctags use heuristics which cannot tell for sure what is the correct definition. Instead of those tools, you can use rtags and/or YouCompleteMe which are based on the clang library. Those tools understand c or c++ and can jump to the correct definition. See: https://github.com/Valloric/YouCompleteMe https://github.com/Andersbakken/rtags https://github.com/lyuts/vim-rtags Regards Dominique -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
