Mkproto takes a re-directed input from standard in of one C source code file, and produces as output (on the standard output stream) a list of function prototypes (a la ANSI) for the external functions defined in the given source files. This output, redirected to a file, is suitable for #include'ing in a C source file.
It can be executed as follows:
% mkproto {options} < file.c
or,
% mkproto {options} < file.c > file.h
The function definitions in the original source may be either "old-style" (in which case appropriate prototypes are generated for the functions) or "new-style" (in which the definition includes a prototype already).
A -n option causes the line number where each function was defined to be prepended to the prototype declaration as a comment.
A -s option causes prototypes to be generated for functions declard "static" as well as extern functions.
A -p option causes the prototypes emitted to be only readable by ANSI compilers. Normally, the prototypes are "macro-ized" so that compilers with __STDC__ not defined don't see them.
Mkproto is easily confused by complicated declarations, such as int ((*signal)())() { ...
or struct foo { int x, y; } foofunc() { ...
Float types are not properly promoted in old style definitions, i.e. int test(f) float f; { ...
should (because of the default type conversion rules) have prototype int test(double f);
rather than the incorrect int test(float f);
generated by mkproto.
Some programs may need to be run through the preprocessor before being run through mkproto. The -n option is unlikely to work as desired on the output of a preprocessor.
Typedef'd types aren't correctly promoted, e.g. for typedef schar char; int foo(x) schar x;...
mkproto incorrectly generates the prototype int foo(schar x) rather than the (correct) int foo(int x).
Functions named "inline" with no explicit type qualifiers are not recognized.
Original source from:
Eric R. Smith email: Dept. of Mathematics ersmith@uwovax.uwo.ca University of Western Ontario ersmith@uwovax.bitnet London, Ont. Canada N6A 5B7 ph: (519) 661-3638