Listtree.mcc: rename variables in Listtree_GetEntry to match the template of other...
[AROS.git] / tools / cxref / FAQ
bloba4427ed2f41b01bcff01e7de42cd9098d9d245f7
1           CXREF VERSION 1.5 - FREQUENTLY ASKED QUESTIONS AND ANSWERS
2           ==========================================================
4 This file contains a list of frequently asked questions and their answers
5 relating to cxref version 1.5.
7 Not all of the questions here are real users questions, some of them have been
8 made up to give some help to people trying to use the program who find that the
9 README documentation is insufficient.
11 --------------------------------------------------------------------------------
13 Section 0 - Why doesn't this FAQ answer my question?
15 --------------------
17 Section 1 - What does cxref do (and what it doesn't)
19 Q 1.1   Does cxref support C++?
20 Q 1.2   Does cxref show which #includes that are not needed?
21 Q 1.3   Can cxref document automatic function variables?
22 Q 1.4   Does cxref run on systems other than UNIX?
24 --------------------
26 Section 2 - When cxref does not work
28 Q 2.1a  How do I find out what is causing the parse error?
29 Q 2.1b  What does this parse error message mean?
30 Q 2.2   Where are files doc/cxref.html & FAQ.html referenced from README.html?
31 Q 2.3   Why are half of the cross references missing?
32 Q 2.4   Why can't cxref process my header file in isolation?
33 Q 2.5   Why can't LaTeX process the output files?
34 Q 2.6   Why does the include file name have the complete path name?
35 Q 2.7   Why does the include file name have the wrong path name?
36 Q 2.8   Why does cxref put in links to system include files?
38 --------------------
40 Section 3 - How to make cxref do what you want
42 Q 3.1   How do I use cxref to process source files in more than one directory?
43 Q 3.2   How can I add my own information to the output files?
44 Q 3.3   Can I get a subset of the cross-reference information?
45 Q 3.4   Is there an easy way to generate the comments in the correct format?
46 Q 3.5   How do I produce LaTeX output from a single source.c.tex output file?
47 Q 3.6   How can I pass extra arguments to the C pre-processor?
48 Q 3.7   Can I cross-reference my source code at the same time as compiling it?
49 Q 3.8   What use is the .cxref configuration file?
51 --------------------
53 Section 4 - More information about cxref
55 Q 4.1   Who wrote cxref, When and Why?
56 Q 4.2   How do I report bugs in cxref?
58 --------------------------------------------------------------------------------
60 Section 0 - Why doesn't this FAQ answer my question?
62 This FAQ is released with each new version of the cxref program, so if the
63 question is one that is frequently asked about the new version then you will by
64 definition not find the answer here.
66 You can find the latest information about cxref at the cxref web-page, this
67 contains among other things a list of bug-fixes for the latest version.
69 http://www.gedanken.demon.co.uk/cxref/
71 --------------------------------------------------------------------------------
73 Section 1 - What does cxref do (and what it doesn't)
75 --------------------
77 Q 1.1   Does cxref support C++?
79 No.
81 The cxref program only works for C, More specifically:
83 1) ANSI standard C with some leniency for common non-ANSI syntax.
84         For example, the construct 'switch(foo) { case 1: ... default: }' is not
85         ANSI, there must be a ';' after the default label, but it is accepted by
86         cxref.
88 2) Traditional (K&R) function declarations, with implicit 'int' and 'void'.
89         For example 'foo(){}' is parsed as if 'int foo(void){}' was specified.
91 3) The ability to parse GCC extensions.
92         The GCC '__attribute__' and '__extension__' keywords and most of the
93         other GCC extensions. The 'inline' keyword is allowed.
95 --------------------
97 Q 1.2   Does cxref show which #includes that are not needed?
99 No.
101 The output of the cxref program cross-references all of the functions,
102 variables, type definitions, included file etc.  There is not a way of
103 identifying files that are included in another source file that do not need to
106 --------------------
108 Q 1.3   Can cxref document automatic function variables?
112 The inclusion of automatic variables in the output is not included.  This is
113 because of the number of them in a typical function.  In theory it could be made
114 to do this.
116 --------------------
118 Q 1.4   Does cxref run on systems other than UNIX?
120 For example DOS / Win3 / Win95 / WinNT / OS/2.
122 UNIX    = Yes
123         This is the system that the program way designed and initially written
124         for, it should work on many versions of UNIX.
125         I know that it works on Linux, SunOS 4.1.x, Solaris 2.x, AIX & HP-UX 10.
127 DOS/Win3 = No
128         The program was not designed for DOS, the filenames used and the
129         multi-process nature of the program do not allow this.
131 Win95/WinNT = Yes
132         Using the Cygwin library and tools http://sourceware.cygnus.com/cygwin/
133         it is possible to compile and run the programs.
135 OS/2    = Maybe
136         I have reports that it is possible with OS/2 Warp with emx, but I do not
137         support cxref for this OS.
139 --------------------------------------------------------------------------------
141 Section 2 - When cxref does not work
143 --------------------
145 Q 2.1a  How do I find out what is causing the parse error?
147 The following error message is generated by cxref when parsing a source file
148 (with YYDEBUG set to 0 in parse-yy.h when cxref was compiled).
150 test.c:   4: parse error, expecting `','' or `';''
151 ^^^^^^  ^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152 file    line            type of error
153 name    number        generated by yacc
155 The error is on line 4 of the file test.c.  In this case, the error message that
156 the yacc parser is generating is of some help, more often the error message is
157 just 'parse error'.
159 If YYDEBUG was set to 1 in parse-yy.h, then a more detailed error message would
160 be given (See Q 2.1b).
163 Q 2.1b  What does this parse error message mean?
165 The following error message is generated by cxref when parsing a source file
166 (with YYDEBUG set to 1 in parse-yy.h when cxref was compiled).
168 test.c:   4: parse error, expecting `','' or `';''
170 The previous 10, current and next 10 symbols are:
171  -8 | 296 :              INT : int
172  -7 | 258 :       IDENTIFIER : foo
173  -6 |  40 :                  : (
174  -5 | 292 :             VOID : void
175  -4 |  41 :                  : )
176  -3 | 123 :                  : {
177  -2 | 296 :              INT : int
178  -1 | 258 :       IDENTIFIER : a
179   0 | 296 :              INT : int
180   1 | 258 :       IDENTIFIER : b
181   2 |  59 :                  : ;
182   3 | 125 :                  : }
183 END OF FILE
184 ^^^               ^^^^^^^^^^  ^^^^^
185 symbol              symbol    symbol
186 number               type     value
188 From this we can reconstruct part of the file test.c, using the previous and
189 next 10 symbol values from the lexer.
191 int foo(void) { int a   int b; }
192                       ^
193 This is where the parse error occurred, after 'int a' and before 'int b;'.
194 The cause of the error is now clear, there is a ';' missing after the
195 declaration of the variable a.
197 The cxref program is intended to be used on source files that are known to
198 compile with a C compiler.  In this case a parse error message should not be
199 seen except for either non-standard C, (and compiler) or a bug in cxref.
201 --------------------
203 Q 2.2   Where are files doc/cxref.html & FAQ.html referenced from README.html?
205 The README.html file has a reference to the files doc/cxref.html and FAQ.html
206 these files are only present when 'make docs' has been run to generate the cross
207 references for the cxref program itself.
209 --------------------
211 Q 2.3   Why are half of the cross references missing?
213 The way that cxref works is that it processes all of the source files for a
214 program, one at a time and generates a cross reference database.  A second pass
215 of the program is required to generate all of the cross references from the
216 database of cross reference information.
218 For this reason, the Makefile for the doc directory of cxref uses 'cxref *.c
219 -xref -Odoc' for the first pass and 'cxref *.c -xref -Odoc -html -latex' for the
220 second pass.  The first to build the database, the second to produce the
221 outputs.
223 The reason that the cross references are missing is that only one pass of the
224 program has been done on all of the files.  The later files to be be processed
225 will have cross references for the earlier files processed.
227 --------------------
229 Q 2.4   Why can't cxref process my header file in isolation?
231 The cxref program needs to process the header files to enable a cross reference
232 for them to be generated.  In many cases, the header file will not have been
233 written with this in mind, and may rely on other header files being included
234 before the one being processed.  The best solution to this is to modify the
235 header file so that it includes all of the header files that it needs.
237 Another option is to use '-- -include filename.h' on the command line.  This
238 will include the specified file (filename.h) into the source file that is being
239 processed at the beginning.
241 There is a Perl script supplied with the cxref source files called fixheader.
242 This can be used to automatically determine what header files may be required.
243 The decision is based on the header files that are used for the files that cxref
244 can process and lots of test compilations.
246 --------------------
248 Q 2.5   Why can't LaTeX process the output files?
250 There are two options for producing LaTeX output, '-latex' and '-latex2e'.
251 These refer to two different versions of the LaTeX program.  The first is for
252 use with LaTeX version 2.0.9, the second for use with LaTeX version 2e.
254 The file cxref.tex (or basename.tex if '-Nbasename' is used) is the file that
255 must be processed by LaTeX.
257 --------------------
259 Q 2.6   Why does the include file name have the complete path name?
261 This is because a standard C preprocessor is being used instead of cxref-cpp or
262 an appropriate version of gcc.  One of the changes to the recent versions of gcc
263 (2.8.0) has been made to the GNU cccp to make cxref-cpp.  This is to make it
264 output the names of the include files as they are in the original source code
265 and not after the files have been translated into an absolute pathname.
267 --------------------
269 Q 2.7   Why does the include file name have the wrong path name?
271 If the answer to this question is not the same as the answer to Q 2.6 then it
272 could be the following.  When the files that are being cross-referenced are in a
273 directory that contains a symbolic link in the path then the current directory
274 has two (or more) possible names.  The way that the cxref program works is that
275 it finds the current working directory (which is the real pathname, not using
276 any links).  If the name that you specify using -R is another name for the same
277 directory then cxref will not realise that they are the same.  This can cause
278 the pathnames to become confused.  Try using relative pathnames where possible
279 for the -R and -I options.
281 --------------------
283 Q 2.8   Why does cxref put in links to system include files?
285 The way that cxref knows which include files are local to the program and which
286 ones are system ones is by the way that they are included.  Any that use double
287 quotes '"' are local ones and wil have links to them included in the cross
288 reference output.  The include files that use the angle brackets '<>' are system
289 files and do not have links to them included.
291 The best solution is to change the include files so that the distinction is
292 clear.  An alternative is to use the '-isystem DIRNAME' option of gcc.  This
293 will cause gcc to treat files in this directory as if they are system files.
294 Since cxref uses gcc for the pre-processing, this option can be passed through
295 using 'cxref file.c -- -isystem DIRNAME'.
297 --------------------------------------------------------------------------------
299 Section 3 - How to make cxref do what you want
301 --------------------
303 Q 3.1   How do I use cxref to process source files in more than one directory?
305 The cxref program depends on a database of cross references, these must all be
306 consistent.  This requires that all of the files to be cross referenced are in
307 the same directory tree.
309 Example:
311 directory     files
312 - - - - -     - - -
313 basedir    :  f0.c f0.h ...
314  |- s1     :  f1.c f1.h ...
315  |- s2     :  f2.c f2.h ...
318 -- f2.c --
319 #include <...>
320 #include "f2.h"
321 #include "../s1/f1.h"
322 #include "f0.h"
323 ----------
325 In the base directory 'basedir' run 'cxref -xref -Odoc s2/f2.c -html -I.'.  This
326 will create the file 'doc/s2/f2.c.html' for the file 'f2.c' and this will
327 contain references to the files 'doc/s2/f2.h.html', 'doc/s1/f1.h.html' and
328 'doc/f0.h.html'.  The subdirectories 'doc/s1', 'doc/s2' will be automatically
329 created within the 'doc' directory to put the files into (the 'doc' directory
330 must already exist).
332 directory        files
333 - - - - -        - - -
334 basedir
335  |- doc       :  f0.c.html f0.h.html ... cxref.html
336      |- s1    :  f1.c.html f1.h.html ...
337      |- s2    :  f2.c.html f2.h.html ...
340 An alternative method is to use the -R option to cxref.  In the directory 's2',
341 cxref can be run as 'cxref -R.. -xref -Odoc f2.c -html -I.'.  This will change
342 directory to '..' ('basedir') before cxref is run, and will modify the cxref
343 arguments so that it is equivalent to running cxref from 'basedir' as detailed
344 above.
346 --------------------
348 Q 3.2   How can I add my own information to the output files?
350 The files cxref.html and cxref.tex (depending on whether using HTML or LaTeX
351 format and the use of the '-Nbasename' option) are the ones to edit.  These
352 files contain the lines 'Begin-Of-Source-Files' and 'End-Of-Source-Files' as
353 comments.  The output files for each source file are automatically included
354 between these lines if they do not already exist there.  The order of these
355 files and any other text between these lines is not important.  Customisation of
356 the files should be added here.  The output files for each source file are
357 automatically generated so any edits made to these will be lost when cxref is
358 run.
360 --------------------
362 Q 3.3   Can I get a subset of the cross-reference information?
364 At the moment, the only one way to limit the amount of cross referencing is to
365 use the '-xref-*' command line option (see README).  There are plans for a
366 future version of cxref to have an options file that would allow different
367 amounts of information to be generated in the output.  For example, only to
368 display called and not calls information for each function.
370 --------------------
372 Q 3.4   Is there an easy way to generate the comments in the correct format?
374 The only easy way to do this is to use the cxref.el macro file and Emacs.  This
375 is what is used to generate the comments in the cxref source code itself.
377 --------------------
379 Q 3.5   How do I produce LaTeX output from a single source.c.tex output file?
381 The file cxref.tex (or basename.tex if '-Nbasename' is used) is the file that
382 must be processed by LaTeX.  All of the individual LaTeX files for the source
383 files are included into this file.  If an individual file source.c.tex needs to
384 be processed then a copy of the file cxref.tex should be modified to include
385 only the required source.c.tex file.
387 --------------------
389 Q 3.6   How can I pass extra arguments to the C pre-processor?
391 The cxref program itself has three ways that you can specify the arguments that
392 are passed to the C pre-processor.
394 a) The -CPP option allows the name of the pre-processor program itself to be
395    changed.
396    e.g. 'cxref -CPP "/usr/foo/cpp -C" foo.c' will use the cpp from /usr/foo
397    instead of the compiled in default and pass it the option -C.
399 b) The most common C pre-processor commands are recognised by cxref
400    automatically, these are -D*, -U* and -I*.
402 c) Any amount of extra options can be passed to the preprocessor by appending
403    them to the command line after the end-of-arguments marker '--'.
404    e.g. 'cxref foo.c -- -traditional' will pass -traditional to the
405    pre-processor.
407 --------------------
409 Q 3.7   Can I cross-reference my source code at the same time as compiling it?
411 It is possible to cross-reference and document your source code at the same time
412 as compiling it by using the cxref-cc script.  This takes the same arguments as
413 your usual C compiler and performs both functions.
415 First it calls the C compiler and passes on all of the command line arguments.
416 The real C compiler is specified by the CXREFCC environment variable, or the CC
417 environment variable or it will use gcc if neither of these are set.
419 Second the arguments that cxref needs to have are extracted from the arguments
420 that the C compiler had and cxref is called.  The arguments that are kept are
421 the -D*, -U*, -I* arguments to specify #defines and #include paths, and the file
422 name of the source file itself.  Any other arguments are taken from the .cxref
423 file (See Q 3.8).
425 After doing this it will still be necessary to sort out the header files since
426 these are not cross-referenced using this method.
428 --------------------
430 Q 3.8   What use is the .cxref configuration file?
432 The most obvious use is if you have a lot of command line options that you don't
433 want to have to enter every time that you run the program.
435 However the .cxref file is most useful when you have a multiple directory source
436 tree (See< Q 3.1), or when you are using an existing Makefile to build
437 documentation.
439 When there are various subdirectories containing source code, a .cxref file in
440 each sub-directory can be used just containing the line '-R..' or whatever is
441 appropriate to point cxref to the root of the source tree.  This means that
442 there is no need to keep track of which directory you are in, they all will use
443 the correct directory to work from.
445 If you already have a Makefile that goes through all of the source code then you
446 may want to modify it so that it calls cxref instead of calling the C compiler.
447 This means that there is no room to put the extra arguments to cxref on the
448 command line.  A .cxref file can contain the command line arguments so that you
449 only need to need the arguments that are already there for the C compiler
450 (See Q 3.7).
452 --------------------------------------------------------------------------------
454 Section 4 - More information about cxref
456 --------------------
458 Q 4.1   Who wrote cxref, When and Why?
460 The cxref program was written by Andrew M. Bishop (amb@gedanken.demon.co.uk) in
461 1995,96,97,98,99 and maintained since then.
463 There is a cxref home-page on the World Wide Web, available via the author's
464 home-page at http://www.gedanken.demon.co.uk/ .  This is kept updated with news
465 about the program, as new versions become available.
467 An earlier program by the same author using basically the same comment
468 convention was written in Emacs Lisp in 1994.  This version was slow, the amount
469 of cross referencing was poor and the output was only in troff format.  The
470 current C program was written to replace this but has grown to become much
471 better in the cross referencing that is done and the format of the output has
472 increased greatly.
474 The cxref program can be freely distributed according to the terms of the GNU
475 General Public License (see the file `COPYING').
477 --------------------
479 Q 4.2   How do I report bugs in cxref?
481 By e-mail, send them to me at amb@gedanken.demon.co.uk and put cxref somewhere
482 in the subject line.  You can also report bugs or provide comments via the
483 feedback form on the cxref home-page on the World Wide Web accessible via
484 http://www.gedanken.demon.co.uk/ .
486 Before doing this, you should check the FAQ and the cxref web-page to see if the
487 answer is there.  If it is not, and it is a parse error then check that it is a
488 cxref problem and not a syntax error in the source file.
489 When you are sure that it is a cxref bug, give me as much information as you
490 can, about the error, when it happens, what system you are using etc.  It is
491 useful if you can provide a small example and the output of using the '-raw'
492 option to provide the actual output that you are seeing.  (If it is an HTML or
493 LaTeX specific problem then send that file instead.)
495 --------------------------------------------------------------------------------