C++ cross referencer

J

John Goche

Hello,

When reading source code, perhaps written by others and
consisting of a large number of files organized into a large
number of directories, several identifiers of unknown origin,
purpose, or use are encountered. In these cases it is nice
to be able to click on such an identifier to be able to bring
up a list of all files in the source code in which such an
identifier appears with the file path displayed as part of
the filename. Then it is nice to click on such filenames
to bring up the contents of the file with the line on which
the first occurrence of such an identifier appears displayed.
Such identifiers may be class names, function names,
enumerated values, data types, and so on. For instance
it may be that the header and source file for a member
function do not start with the same name and hence it
is difficult to find one given the other. We may want to
jump from header file to source file or vice versa. When
coming across an enumerated value in a class function,
it may not be clear where it is defined as it may be that
it is defined somewhere up in the class hierarchy for the
containing class, or perhaps in the global namespace.
Other times we may simply want to know in which
context a certain function is used so that when
rearranging code we don't break other code.
The number of situations is countless, but
what we need to do is quickly jump around,
from an identifier to other places in which it
appears, and from function definition to the
place where it is declared or from enumerated
value to the place where it is defined, or from
type definition to the place where it is typedef'd.
Anyone is welcome to add to the list. However,
what I would really like is some pointers to some
free cross-references that allowed you to do all of
this in one shot, allowing you to define the location
of the source code repository and let you jump from
place to place. Also, anyone know if a simple editor
like vim is able to support anything like that? I would
like to know about any other good free (or commercial)
tools or IDEs that can serve the purpose described.

Thanks,

JG
 
B

Bart

John said:
Hello,

When reading source code, perhaps written by others and
consisting of a large number of files organized into a large
number of directories, several identifiers of unknown origin,
purpose, or use are encountered. In these cases it is nice
to be able to click on such an identifier to be able to bring
up a list of all files in the source code in which such an
identifier appears with the file path displayed as part of
the filename. Then it is nice to click on such filenames
to bring up the contents of the file with the line on which
the first occurrence of such an identifier appears displayed.
Such identifiers may be class names, function names,
enumerated values, data types, and so on. For instance
it may be that the header and source file for a member
function do not start with the same name and hence it
is difficult to find one given the other. We may want to
jump from header file to source file or vice versa. When
coming across an enumerated value in a class function,
it may not be clear where it is defined as it may be that
it is defined somewhere up in the class hierarchy for the
containing class, or perhaps in the global namespace.
Other times we may simply want to know in which
context a certain function is used so that when
rearranging code we don't break other code.
The number of situations is countless, but
what we need to do is quickly jump around,
from an identifier to other places in which it
appears, and from function definition to the
place where it is declared or from enumerated
value to the place where it is defined, or from
type definition to the place where it is typedef'd.
Anyone is welcome to add to the list. However,
what I would really like is some pointers to some
free cross-references that allowed you to do all of
this in one shot, allowing you to define the location
of the source code repository and let you jump from
place to place. Also, anyone know if a simple editor
like vim is able to support anything like that? I would
like to know about any other good free (or commercial)
tools or IDEs that can serve the purpose described.

I use Microsoft Visual Studio (commercial) for C++ and NetBeans IDE
(free) for Java. Both have code browsing and refactoring tools similar
to what you describe.

Regards,
Bart.
 
G

Gianni Mariani

John said:
Hello,

When reading source code, perhaps written by others and ....
tools or IDEs that can serve the purpose described.

I sometimes run doxygen over an unknown codebase.
 
M

Marcus Kwok

In comp.lang.c++ John Goche said:
When reading source code, perhaps written by others and
consisting of a large number of files organized into a large
number of directories, several identifiers of unknown origin,
purpose, or use are encountered. In these cases it is nice
to be able to click on such an identifier to be able to bring
up a list of all files in the source code in which such an
identifier appears with the file path displayed as part of
the filename. Then it is nice to click on such filenames
to bring up the contents of the file with the line on which
the first occurrence of such an identifier appears displayed.
Such identifiers may be class names, function names,
enumerated values, data types, and so on. For instance
it may be that the header and source file for a member
function do not start with the same name and hence it
is difficult to find one given the other. We may want to
jump from header file to source file or vice versa. When
coming across an enumerated value in a class function,
it may not be clear where it is defined as it may be that
it is defined somewhere up in the class hierarchy for the
containing class, or perhaps in the global namespace.
Other times we may simply want to know in which
context a certain function is used so that when
rearranging code we don't break other code.
The number of situations is countless, but
what we need to do is quickly jump around,
from an identifier to other places in which it
appears, and from function definition to the
place where it is declared or from enumerated
value to the place where it is defined, or from
type definition to the place where it is typedef'd.
Anyone is welcome to add to the list. However,
what I would really like is some pointers to some
free cross-references that allowed you to do all of
this in one shot, allowing you to define the location
of the source code repository and let you jump from
place to place. Also, anyone know if a simple editor
like vim is able to support anything like that? I would
like to know about any other good free (or commercial)
tools or IDEs that can serve the purpose described.

You should look into ctags.
 
M

Marcus Kwok

In comp.lang.c++ Roland Pibinger said:
Can it reasonably handle C++?

Exuberant Ctags claims support for over 33 different languages,
including C++.

http://ctags.sourceforge.net/desire.html
What makes this implementation of ctags desirable?
....
2. It is capable of generating tags for all types of C/C++ language tags,
including all of the following:

- class names
- macro definitions
- enumeration names
- enumerators
- function definitions
- function prototypes/declarations
- class, interface, struct, and union data members
- structure names
- typedefs
- union names
- variables (definitions and external declarations)

Also, from http://ctags.sourceforge.net/faq.html#7 :

If you specify the --extra=+q option, then ctags will also generate
a second, class-qualified tag for each class member (data and
function/method) in the form class::member for C++

which allows you to jump to class-qualified identifiers as well.
 
J

John Goche

Marcus said:
Exuberant Ctags claims support for over 33 different languages,
including C++.

http://ctags.sourceforge.net/desire.html
What makes this implementation of ctags desirable?
...
2. It is capable of generating tags for all types of C/C++ language tags,
including all of the following:

- class names
- macro definitions
- enumeration names
- enumerators
- function definitions
- function prototypes/declarations
- class, interface, struct, and union data members
- structure names
- typedefs
- union names
- variables (definitions and external declarations)

Also, from http://ctags.sourceforge.net/faq.html#7 :

If you specify the --extra=+q option, then ctags will also generate
a second, class-qualified tag for each class member (data and
function/method) in the form class::member for C++

which allows you to jump to class-qualified identifiers as well.

I have been using LXR from http://lxr.sourceforge.net/. This tool
is really not bad. However, it lacks the class-qualified tags you
describe.

Thanks,

JG
 
J

jussij

John said:
Also, anyone know if a simple editor like vim is able to
support anything like that?

The Zeus for Windows IDE (shareware) can automatically manage
the creation of tags for a set of project files and it displays
the tags information in a class browsing tree:

http://www.zeusedit.com/features.html

It has options to search and navigate the tree, allowing you
to easily jump to the definition and implementation details
but the tree does not contains any xref details.

Jussi Jumppanen
Author: Zeus for Windows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top