Code Query

Published:
1 minute read

Find the complete manuals here:

  1. How-to for Linux
  2. How-to for Windows

HOW TO USE CODEQUERY WITH C/C++ CODE?

Change directory to the base folder of your source code like this:

cd ~/projects/myproject/src

Create a cscope.files file with all the C/C++ source files listed in it. Files with inline assembly code should be excluded from this list.

find . -iname "*.c"    > ./cscope.files
find . -iname "*.cpp" >> ./cscope.files
find . -iname "*.cxx" >> ./cscope.files
find . -iname "*.cc " >> ./cscope.files
find . -iname "*.h"   >> ./cscope.files
find . -iname "*.hpp" >> ./cscope.files
find . -iname "*.hxx" >> ./cscope.files
find . -iname "*.hh " >> ./cscope.files

Create a cscope database like this (add k, if you don’t want standard include paths like for stdio.h):

cscope -cb

Create a ctags database like this.

ctags --fields=+i -n -L ./cscope.files

Run cqmakedb to create a CodeQuery database out of the cscope and ctags databases, like this:

cqmakedb -s ./myproject.db -c ./cscope.out -t ./tags -p

Open myproject.db using the CodeQuery GUI tool by running the following. Wild card search (* and ?) supported if Exact Match is switched off. Or use cqsearch, the CLI-version of CodeQuery (type cqsearch -h for more info).

codequery

Use cqmakedb -h to get help on cqmakedb command line arguments.

Resources