next up previous contents
Next: C++ Up: Draw PAD figure directly Previous: Draw PAD figure directly




When drawing a PAD figure directly from C program, type in:

% pad2ps -c foo.c > foo.ps

You do not have to specify the option -c  if the suffix of the input file is .c.

A parser of C language is c2pad . To execute this parser directly and convert program into PADEL, type in:

% mkpad -c foo.c > foo.pad

In this case you cannot omit the option -c.

When processing C program, each function will become a PAD figure. Each function name becomes the corresponding PAD's title. All global variables outside function is discarded. You can also discard variable declarations without initialization by setting -O  option, even if the declaration is made inside function.

By defalut, ; (semicolumn) at end of line is not printed in PAD figure. By setting -semicolon  option, you can override this.

The most important point when converting C program is conditional compile controller, such as #ifdef. For example, you are to create PAD figure of foo.c. If you have set -DENGLISH when you compiled foo.c like the following:

% gcc foo.c -DENGLISH

then you also have to set the same option when you let pad2ps series draw PAD figure. This is accomplished using -D  option:

% pad2ps foo.c -D ENGLISH > foo.ps

Notice that the way of setting option is slightly different from that of C compiler.

There are some symbols, however, that are automatically defined by C compiler. Besides pad2ps series ignore #include <stdio.h> so the symbols defined in header files are also missed. Therefore you should define all the symbols that should be defined with -D option. You can list up all the symbols which have something to do with conditional compilation with -ifdef option. Here is an example:

% pad2ps foo.c -ifdef

You should be able to draw PAD figures for most of your C programs. Only exception case is programs that do not match with C syntax in appearance due to macros. Especially a macro command which doesn't end with ';' (a semicolon) like:

#define NUMBER(X) { int a; for( a='0' ; a<=X ; a++) putchar(a);}
puts(``Print Numbers'');
putchar(' tex2html_wrap_inline2568 n');

often causes an error.

In this case, the only solution is to modify it manually. Even if no errors occur, output PAD figure may be incorrect. After all you have to pay special attention when drawing PAD figure of a program with many macros.


next up previous contents
Next: C++ Up: Draw PAD figure directly Previous: Draw PAD figure directly


Go back to pad2ps - automatic PAD drawer.
Go back to Seiichi Yoshida's Home Page.
Copyright(C) Seiichi Yoshida (comet@aerith.net). All rights reserved.
Sun Nov 10 01:36:04 JST 1996