1CPROTO(1)                   General Commands Manual                  CPROTO(1)
2
3
4

NAME

6       cproto  -  generate  C function prototypes and convert function defini‐
7       tions
8

SYNOPSIS

10       cproto [ option ...  ] [ file ...  ]
11

DESCRIPTION

13       Cproto generates function prototypes for functions defined in the spec‐
14       ified  C source files to the standard output.  The function definitions
15       may be in the old style or ANSI C style.  Optionally, cproto also  out‐
16       puts declarations for variables defined in the files.  If no file argu‐
17       ment is given, cproto reads its input from the standard input.
18
19       By giving a command line option, cproto will also convert function def‐
20       initions in the specified files from the old style to the ANSI C style.
21       The original source files along with files specified by
22       #include "file"
23       directives appearing in the source code will be  overwritten  with  the
24       converted  code.   If no file names are given on the command line, then
25       the program reads the source code from the standard input  and  outputs
26       the converted source to the standard output.
27
28       If  any  comments  appear  in the parameter declarations for a function
29       definition, such as in the example,
30       main (argc, argv)
31       int argc;       /* number of arguments */
32       char *argv[];   /* arguments */
33       {
34       }
35       then the converted function definition will have the form
36       int
37       main (
38           int argc,       /* number of arguments */
39           char *argv[]   /* arguments */
40       )
41       {
42       }
43       Otherwise, the converted function definition will look like
44       int
45       main (int argc, char *argv[])
46       {
47       }
48
49       Cproto can optionally convert function definitions from the ANSI  style
50       to  the  old  style.   In this mode, the program also converts function
51       declarators and prototypes that appear outside function  bodies.   This
52       is  not  a  complete  ANSI C to old C conversion.  The program does not
53       change anything within function bodies.
54
55       Cproto can optionally generate source in lint-library format.  This  is
56       useful  in  environments  where  the lint utility is used to supplement
57       prototype checking of your program.
58

OPTIONS

60       -e     Output the keyword extern in front of every generated  prototype
61              or declaration that has global scope.
62
63       -f n   Set the style of generated function prototypes where n is a num‐
64              ber from 0 to 3.  For example, consider the function definition
65              main (argc, argv)
66              int argc;
67              char *argv[];
68              {
69              }
70              If the value is 0, then no prototypes are generated.   When  set
71              to 1, the output is:
72              int main(/*int argc, char *argv[]*/);
73              For a value of 2, the output has the form:
74              int main(int /*argc*/, char */*argv*/[]);
75              The  default  value  is 3.  It produces the full function proto‐
76              type:
77              int main(int argc, char *argv[]);
78
79       -l     Generate text for a lint-library (overrides  the  "-f"  option).
80              The output includes the comment
81              /* LINTLIBRARY */
82              Special  comments  LINT_EXTERN  and LINT_PREPRO (a la "VARARGS")
83              respectively turn on the "-x" option and  copy  comment-text  to
84              the output (for preprocessing in lint).  Use the comment
85              /* LINT_EXTERN2 */
86              to  include externs defined in the first level of include-files.
87              Use the comment
88              /* LINT_SHADOWED */
89              to cause cproto to put  "#undef"  directives  before  each  lint
90              library  declaration  (i.e., to avoid conflicts with macros that
91              happen to have to have the same  name  as  the  functions,  thus
92              causing syntax errors).
93
94       Note that these special comments are not supported under VAX/VMS, since
95       there is no equivalent for the "-C" option of cpp with VAX-C.
96
97       -c     The parameter comments in the prototypes generated  by  the  -f1
98              and  -f2  options  are  omitted  by default.  Use this option to
99              enable the output of these comments.
100
101       -m     Put a macro around the parameter list of every generated  proto‐
102              type.  For example:
103              int main P_((int argc, char *argv[]));
104
105       -M name
106              Set  the  name of the macro used to surround prototype parameter
107              lists when option -m is selected.  The default is "P_".
108
109       -d     Omit the definition of  the  prototype  macro  used  by  the  -m
110              option.
111
112       -o file
113              Specify the name of the output file (default: standard output).
114
115       -O file
116              Specify the name of the error file (default: standard error).
117
118       -p     Disable  promotion  of  formal  parameters in old style function
119              definitions.  By default, parameters of type char  or  short  in
120              old  style  function definitions are promoted to type int in the
121              function prototype or  converted  ANSI  C  function  definition.
122              Parameters of type float get promoted to double as well.
123
124       -q     Do  not  output  any error messages when the program cannot read
125              the file specified in an #include directive.
126
127       -s     By default, cproto only generates declarations for functions and
128              variables  having  global scope.  This option will output static
129              declarations as well.
130
131       -S     Output only static declarations.
132
133       -i     By default, cproto only generates declarations for functions and
134              variables  having  global scope.  This option will output inline
135              declarations as well.
136
137       -T     Copy  type  definitions  from  each   file.    (Definitions   in
138              included-files are copied, unlike the "-l" option).
139
140       -v     Also output declarations for variables defined in the source.
141
142       -x     This  option  causes procedures and variables which are declared
143              "extern" to be included in the output.
144
145       -X level
146              This option limits the include-file level  from  which  declara‐
147              tions are extracted by examining the preprocessor output.
148
149       -a     Convert  function  definitions  from the old style to the ANSI C
150              style.
151
152       -t     Convert function definitions from the ANSI C style to the tradi‐
153              tional style.
154
155       -b     Rewrite  function definition heads to include both old style and
156              new style declarations separated by  a  conditional  compilation
157              directive.   For example, the program can generate this function
158              definition:
159              #ifdef ANSI_FUNC
160
161              int
162              main (int argc, char *argv[])
163              #else
164
165              int
166              main (argc, argv)
167              int argc;
168              char *argv[]
169              #endif
170              {
171              }
172
173       -B directive
174              Set the conditional  compilation  directive  to  output  at  the
175              beginning  of  function  definitions generated by the -b option.
176              The default is
177              #ifdef ANSI_FUNC
178
179       -P template
180       -F template
181       -C template
182            Set the output format for generated prototypes,  function  defini‐
183            tions,  and  function  definitions with parameter comments respec‐
184            tively.  The format is specified by a template in the form
185            " int f ( a, b )"
186            but you may replace each space in this string with any  number  of
187            whitespace characters.  For example, the option
188            -F"int f(\n\ta,\n\tb\n\t)"
189            will produce
190            int main(
191                    int argc,
192                    char *argv[]
193                    )
194
195       -D name[=value]
196              This option is passed through to the preprocessor and is used to
197              define symbols for use with conditionals such as #ifdef.
198
199       -U name
200              This option is passed through to the preprocessor and is used to
201              remove any definitions of this symbol.
202
203       -I directory
204              This option is passed through to the preprocessor and is used to
205              specify a directory to search for files that are referenced with
206              #include.
207
208       -E cpp Pipe  the  input files through the specified C preprocessor com‐
209              mand when generating prototypes.  By default, the  program  uses
210              /lib/cpp.
211
212       -E 0   Do not run the C preprocessor.
213
214       -V     Print version information.
215

ENVIRONMENT

217       The environment variable CPROTO is scanned for a list of options in the
218       same format as the command line options.  Options given on the  command
219       line override any corresponding environment option.
220

BUGS

222       If  an  un-tagged struct, union or enum declaration appears in a gener‐
223       ated function prototype or converted function definition,  the  content
224       of the declaration between the braces is empty.
225
226       The  program  does not pipe the source files through the C preprocessor
227       when it is converting function definitions.  Instead, it tries to  han‐
228       dle  preprocessor  directives  and macros itself and can be confused by
229       tricky macro expansions.  The conversion also discards some comments in
230       the function definition head.
231
232       The -v option does not generate declarations for variables defined with
233       the extern specifier.  This doesn't strictly conform to the C  language
234       standard  but  this rule was implemented because include files commonly
235       declare variables this way.
236
237       When the program encounters an error, it usually outputs the  not  very
238       descriptive  message "syntax error".  (Your configuration may allow the
239       extended error reporting in yyerror.c).
240
241       Options that take string arguments only interpret the following charac‐
242       ter escape sequences:
243       \n   newline
244       \s   space
245       \t   tab
246
247       VARARGS comments don't get passed through on systems whose C preproces‐
248       sors don't support this (e.g., VAX/VMS, MS-DOS).
249

AUTHOR

251       Chin Huang
252       cthuang@vex.net
253       cthuang@interlog.com
254
255       Thomas Dickey
256       dickey@invisible-island.net
257       modifications to support lint library, type-copying, and port to VAX/VMS.
258

SEE ALSO

260       cc(1), cpp(1)
261
262
263
264                                   July 2010                         CPROTO(1)
Impressum