cproto - generate C function prototypes and convert function definitions
By giving a command line option, cproto will also convert function definitions in the specified files from the old style to the ANSI C style. The original source files along with files specified by
#include "file"
directives appearing in the source code will be overwritten with the converted code. If no file names are given on the command line, then the program reads the source code from the standard input and outputs the converted source to the standard output.
If any comments appear in the parameter declarations for a function definition, such as in the example,
main (argc, argv) int argc; /* number of arguments */ char *argv[]; /* arguments */ { }
then the converted function definition will have the form
int main ( int argc, /* number of arguments */ char *argv[] /* arguments */ ) { }
Otherwise, the converted function definition will look like
int main (int argc, char *argv[]) { }
Cproto can optionally convert function definitions from the ANSI style to the old style. In this mode, the program also converts function declarators and prototypes that appear outside function bodies. This is not a complete ANSI C to old C conversion. The program does not change anything within function bodies.
Cproto can optionally generate source in lint-library format. This is useful in environments where the lint utility is used to supplement prototype checking of your program.
main (argc, argv) int argc; char *argv[]; { }
If the value is 0, then no prototypes are generated. When set to 1, the output is:
int main(/*int argc, char *argv[]*/);
For a value of 2, the output has the form:
int main(int /*argc*/, char */*argv*/[]);
The default value is 3. It produces the full function prototype:
int main(int argc, char *argv[]);
/* LINTLIBRARY */
Special comments LINT_EXTERN and LINT_PREPRO (a la "VARARGS") respectively turn on the "-x" option and copy comment-text to the output (for preprocessing in lint). Use the comment
/* LINT_EXTERN2 */
to include externs defined in the first level of include-files. Use the comment
/* LINT_SHADOWED */
to cause cproto to put "#undef" directives before each lint library declaration (i.e., to avoid conflicts with macros that happen to have to have the same name as the functions, thus causing syntax errors). Note that these special comments are not supported under VAX/VMS, since there is no equivalent for the "-C" option of cpp with VAX-C.
int main P_((int argc, char *argv[]));
#ifdef ANSI_FUNC int main (int argc, char *argv[]) #else int main (argc, argv) int argc; char *argv[] #endif { }
#ifdef ANSI_FUNC
-P template -F template -C templateSet the output format for generated prototypes, function definitions, and function definitions with parameter comments respectively. The format is specified by a template in the form
" int f ( a, b )"
but you may replace each space in this string with any number of whitespace characters. For example, the option
-F"int f(\n\ta,\n\tb\n\t)"
will produce
int main( int argc, char *argv[] )
The program does not pipe the source files through the C preprocessor when it is converting function definitions. Instead, it tries to handle preprocessor directives and macros itself and can be confused by tricky macro expansions. The conversion also discards some comments in the function definition head.
The -v option does not generate declarations for variables defined with the extern specifier. This doesn't strictly conform to the C language standard but this rule was implemented because include files commonly declare variables this way.
When the program encounters an error, it usually outputs the not very descriptive message "syntax error". (Your configuration may allow the extended error reporting in yyerror.c).
Options that take string arguments only interpret the following character escape sequences:
\n newline \s space \t tab
VARARGS comments don't get passed through on systems whose C preprocessors don't support this (e.g., VAX/VMS, MS-DOS).
Chin Huang [email protected] [email protected] Thomas Dickey [email protected] modifications to support lint library, type-copying, and port to VAX/VMS.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |