DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C programmer's productivity tools

Using cscope

If all the source files for the program to be browsed (with the possible exception of standard system header files) are in the current directory, invoke cscope without any arguments:

   $ cscope
By default, cscope builds its cross-reference table for all the C, lex, and yacc source files in the current directory. Therefore, typing cscope without any arguments is equivalent to the following command line:
   $ cscope *.[chly]
cscope also searches the standard directories for any header files that you include with #include.

To browse through specific files, invoke cscope with file names as arguments on the command line:

   $ cscope file1.c file2.c file3.h
A list of all the files to be browsed may be read from a file: use the -i option to specify this file. For example:
   $ cscope -i list
If the source files are in a directory tree, the following commands will allow you to examine all the source files easily:
   $ find . -name '*.[chly]' -print | sort > filelist
   $ cscope -i filelist

Searching for #include files

cscope automatically searches for the #include files that it encounters when scanning. The -I option for cscope is similar to the -I option for cc. It directs cscope to search specified directories for #include files. For example:

   $ cscope -I ../hdr
The cscope tool searches for #include files in directories in this order:

  1. the current directory

  2. directories specified by the -I option

  3. the standard location for header files (usually /usr/include).

Searching for source files

By default, cscope searches for source files only in the current directory. The environment variable VPATH can be used to extend your search for source files from a single directory to a set of directories.

VPATH should be set to the list the directories you want searched, in the order you want them searched. Separate the directory names with colons. You must specify the current directory in VPATH if you want it to be searched. The current directory can be represented by the dot ``.'' symbol. The VPATH variable may be set with the commands such as the following:

   $ VPATH=/fs2/mydirectory:/fs1/delivered:/fs1/proj/official:.
   $ export VPATH
These commands may be used on the command line or in a .profile file. In this example, cscope will first search for files in the directory /fs2/mydirectory. If the file is not in that directory, cscope continues searching for it in the other directories specified in VPATH until it finds the file. The current directory, represented by ``.'', is the last directory to be searched in this example.

Next topic: Running cscope
Previous topic: Choosing a browser

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003