Next: Using ASCII Art to Produce Flow Graphs., Previous: Controlling Symbol Types, Up: GNU cflow [Contents][Index]
Cflow
can preprocess input files before analyzing them,
the same way cc
does before compiling. Doing so allows
cflow
to correctly process all symbol declarations, thus
avoiding the necessity to define special symbols using
--symbol option, described in the previous chapter. To enable
preprocessing, run the utility with --cpp
(--preprocess) command line option. For our sample file
d.c, this mode gives:
$ cflow --cpp -n d.c 1 main() <int main (int argc,char **argv) at d.c:85>: 2 fprintf() 3 atoi() 4 printdir() <void printdir (int level,char *name) at d.c:42> (R): 5 getcwd() 6 perror() 7 chdir() 8 opendir() 9 readdir() 10 printf() 11 ignorent() <int ignorent (char *name) at d.c:28>: 12 strcmp() 13 isdir() <int isdir (char *name) at d.c:12>: 14 stat() 15 perror() 16 putchar() 17 printdir() <void printdir (int level,char *name) at d.c:42> (recursive: see 4) 18 closedir()
Compare this graph with the one obtained without --cpp
option (see sample flowchart). As you see, the reference to
S_ISDIR
is gone: the macro has been expanded. Now, try
running cflow --cpp --number -i x d.c
and compare the result
with the graph obtained without preprocessing (see x flowchart). You will see that it produces correct results without
using --symbol option.
By default --cpp runs /usr/bin/cpp. If you wish
to run another preprocessor command, specify it as an argument to the
option, after an equal sign. For example, cflow --cpp='cc
-E'
will run the C
compiler as a preprocessor.
Most projects pass some preprocessor options (-I or
-D) to C compiler command line. Cflow
supports
them as well. Using any of these options enables preprocessing, even
if --cpp is not used explicitly. This facilitates the use of
cflow
in Makefiles, as shown in Using cflow
in Makefiles..
Next: Using ASCII Art to Produce Flow Graphs., Previous: Controlling Symbol Types, Up: GNU cflow [Contents][Index]