NAME mkproto - make prototypes for functions SYNOPSIS mkproto [-n] [-s] [-p] [ file ] ... DESCRIPTION Mkproto takes as input one or more C source code files, 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. 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). OPTIONS -n The line number where each function was defined is prepended to the prototype declaration as a comment. -s Prototypes are generated for functions declard "static" as well as extern functions. -p Prototypes emitted are only readable by ANSI compilers. Normally, the prototypes are "macro-ized" so that compilers with __STDC__ not defined don't see them. -a P((args)) style prototyping. The default is the "Prototype" style commonly used on the Amiga. (I haven't added Locals, MJT) If files are specified on the command line, then a comment specifying the file of origin is emitted before the prototypes constructed from that file. If no files are given, then no comments are emitted and the C source code is taken from the standard input stream. BUGS 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. SEE ALSO cc(1), lint(1) AUTHOR Eric R. Smith. NOTE There is no warranty for this program (as noted above, it's guaranteed to break sometimes anyways!). Mkproto is in the public domain. ADDITIONS By Mike Thomas, mjt@vulcan.anu.edu.au mjt@romeo.anu.edu.au The program has been altered slightly to generate prototypes of the form: Prototype int junk(int i); rather than the type produced by using the new -a command line option: int junk P((int i)); which the program was made to produce originally. This documentation was also altered to reflect the changes, and to add some white space for readability. I have not added Locals. These changes are in the public domain and there is no warranty. There is a similar program around called cproto2 in comp.sources.unix, which I believe would be less prone to errors with complicated declarations (it uses a parser generated by Lex and Yacc). Unfortunately I can't compile it on my 1 Meg Amiga 500 because DICE (my C compiler) runs out of memory, and therefore have not tried it. Let me know if you have an executable I could use.