-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcproto.1
377 lines (375 loc) · 8.97 KB
/
cproto.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
.\" $Id: cproto.1,v 4.9 2010/07/14 09:43:24 tom Exp $
.\"
.de EX \"Begin example
.ne 5
.if n .sp 1
.if t .sp .5
.nf
.in +5n
..
.de EE \"End example
.fi
.in -5n
.if n .sp 1
.if t .sp .5
..
.TH CPROTO 1 "July 2010"
.
.SH NAME
cproto \- generate C function prototypes and convert function definitions
.
.SH SYNOPSIS
.B cproto
[
.I option \fP...\fI
] [
.I file \fP...\fI
]
.
.SH DESCRIPTION
.B Cproto
generates function prototypes for
functions defined in the specified C source files to the standard output.
The function definitions may be in the old style or ANSI C style.
Optionally,
.B cproto
also outputs declarations for variables defined in the files.
If no
.I file
argument is given,
.B cproto
reads its input from the standard input.
.LP
By giving a command line option,
.B 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
.EX
#include "file"
.EE
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.
.LP
If any comments appear in the parameter declarations for a function definition,
such as in the example,
.EX
main (argc, argv)
int argc; /* number of arguments */
char *argv[]; /* arguments */
{
}
.EE
then the converted function definition will have the form
.EX
int
main (
int argc, /* number of arguments */
char *argv[] /* arguments */
)
{
}
.EE
Otherwise, the converted function definition will look like
.EX
int
main (int argc, char *argv[])
{
}
.EE
.LP
.B 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.
.LP
.B Cproto
can optionally generate source in lint\-library format.
This is useful in environments where the \fBlint\fR utility is
used to supplement prototype checking of your program.
.
.SH OPTIONS
.TP
.B \-e
Output the keyword
.B extern
in front of every generated prototype or declaration that has global scope.
.TP
.BI \-f " n"
Set the style of generated function prototypes where
.I n
is a number from 0 to 3.
For example, consider the function definition
.EX
main (argc, argv)
int argc;
char *argv[];
{
}
.EE
If the value is 0, then no prototypes are generated.
When set to 1, the output is:
.EX
int main(/*int argc, char *argv[]*/);
.EE
For a value of 2, the output has the form:
.EX
int main(int /*argc*/, char */*argv*/[]);
.EE
The default value is 3.
It produces the full function prototype:
.EX
int main(int argc, char *argv[]);
.EE
.TP
.B \-l
Generate text for a lint\-library (overrides the "\fB\-f\fR" option).
The output includes the comment
.EX
/* LINTLIBRARY */
.EE
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 \fBlint\fR).
Use the comment
.EX
/* LINT_EXTERN2 */
.EE
to include externs defined in the first level of include\-files.
Use the comment
.EX
/* LINT_SHADOWED */
.EE
to cause
.B 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).
.P
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.
.TP
.B \-c
The parameter comments in the prototypes generated by
the \-f1 and \-f2 options are omitted by default.
Use this option to enable the output of these comments.
.TP
.B \-m
Put a macro around the parameter list of every generated prototype.
For example:
.EX
int main P_((int argc, char *argv[]));
.EE
.TP
.BI \-M " name"
Set the name of the macro used to surround prototype parameter lists
when option \-m is selected.
The default is "P_".
.TP
.B \-d
Omit the definition of the prototype macro used by the \-m option.
.TP
.BI \-o " file"
Specify the name of the output file (default: standard output).
.TP
.BI \-O " file"
Specify the name of the error file (default: standard error).
.TP
.B \-p
Disable promotion of formal parameters in old style function definitions.
By default, parameters of type
.B char
or
.B short
in old style function definitions are promoted to type
.B int
in the function prototype or converted ANSI C function definition.
Parameters of type
.B float
get promoted to
.B double
as well.
.TP
.B \-q
Do not output any error messages when the program cannot read the
file specified in an
.I #include
directive.
.TP
.B \-s
By default,
.B cproto
only generates declarations for functions and variables having global scope.
This option will output
.B static
declarations as well.
.TP
.B \-S
Output only static declarations.
.TP
.B \-i
By default,
.B cproto
only generates declarations for functions and variables having global scope.
This option will output
.B inline
declarations as well.
.TP
.B \-T
Copy type definitions from each file.
(Definitions in included\-files are copied, unlike the "\-l" option).
.TP
.B \-v
Also output declarations for variables defined in the source.
.TP
.B \-x
This option causes procedures and variables which are declared "extern"
to be included in the output.
.TP
.BI \-X " level"
This option limits the include\-file level from which declarations are extracted
by examining the preprocessor output.
.TP
.B \-a
Convert function definitions from the old style to the ANSI C style.
.TP
.B \-t
Convert function definitions from the ANSI C style to the traditional style.
.TP
.B \-b
Rewrite function definition heads to include both old style and new style
declarations separated by a conditional compilation directive.
For example, the program can generate this function definition:
.EX
#ifdef ANSI_FUNC
int
main (int argc, char *argv[])
#else
int
main (argc, argv)
int argc;
char *argv[]
#endif
{
}
.EE
.TP
.BI \-B " directive"
Set the conditional compilation directive to output at the beginning of
function definitions generated by the \-b option.
The default is
.EX
#ifdef ANSI_FUNC
.EE
.LP
.nf
.BI \-P " template"
.BI \-F " template"
.BI \-C " template"
.fi
.in +5n
Set 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
.EX
" int f ( a, b )"
.EE
but you may replace each space in this string with any number of
whitespace characters.
For example, the option
.EX
\-F"int f(\\n\\ta,\\n\\tb\\n\\t)"
.EE
will produce
.EX
int main(
int argc,
char *argv[]
)
.EE
.TP
.BI \-D " name[=value]"
This option is passed through to the preprocessor and is used to define
symbols for use with conditionals such as
.I #ifdef.
.TP
.BI \-U " name"
This option is passed through to the preprocessor and is used to remove
any definitions of this symbol.
.TP
.BI \-I " directory"
This option is passed through to the preprocessor and is used to specify
a directory to search for files that are referenced with
.I #include.
.TP
.BI \-E " cpp"
Pipe the input files through the specified C preprocessor command
when generating prototypes.
By default, the program uses /lib/cpp.
.TP
.BI \-E " 0"
Do not run the C preprocessor.
.TP
.B \-V
Print version information.
.
.SH ENVIRONMENT
The environment variable CPROTO is scanned for
a list of options in the same format as the command line options.
Options given on the command line override any corresponding
environment option.
.
.SH BUGS
If an un\-tagged struct, union or enum declaration appears in
a generated function prototype or converted function definition,
the content of the declaration between the braces is empty.
.LP
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.
.LP
The \-v option does not generate declarations for variables defined with the
.B 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.
.LP
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).
.LP
Options that take string arguments only interpret the following
character escape sequences:
.EX
\\n newline
\\s space
\\t tab
.EE
.LP
VARARGS comments don't get passed through on systems whose C preprocessors
don't support this (e.g., VAX/VMS, MS\-DOS).
.
.SH AUTHOR
.nf
Chin Huang
cthuang@vex.net
cthuang@interlog.com
.sp
Thomas Dickey
dickey@invisible\-island.net
modifications to support lint library, type\-copying, and port to VAX/VMS.
.fi
.
.SH "SEE ALSO"
cc(1),
cpp(1)