MIGRATION commands


PROGRAM NAME

mkproto - Make prototypes for functions

DESCRIPTION

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.

REQUIRED ARGUMENTS

none

OPTIONAL ARGUMENTS

-n
type: boolean
desc: put line numbers of declarations as comments
default: false
-s
type: boolean
desc: include declarations for static functions
default: false
-v
type: boolean
desc: include variable name in declaration
default: false
-d
type: boolean
desc: include declaration for the PROTO() definition
default: false
-p
type: boolean
desc: do not make header files readable by non-ANSI compiler
default: true
-h
type: boolean
desc: do file headers
default: true
-i
type: infile
desc: input file
default: {none}

EXAMPLES

SEE ALSO

cc(1), lint(1)

RESTRICTIONS

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.

REFERENCES

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

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.