tstellar / rpms / gcc

Forked from rpms/gcc 4 years ago
Clone
8b341f8
.\" Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
8b341f8
.\" See section COPYING for conditions for redistribution
8b341f8
.\"
8b341f8
.TH protoize 1 "8 December 2006" "GCC" "GNU"
8b341f8
.SH NAME
8b341f8
protoize, unprotoize \- automatically add or remove function prototypes
8b341f8
.SH SYNOPSIS
8b341f8
.HP 7
8b341f8
\fBprotoize\fR [\-CfgklNnqv] [\-B \fIDIRECTORY\fR] [\-c \fICOMPILATION-OPTIONS\fR] [\-d \fIDIRECTORY\fR] [\-i \fISTRING\fR] [\-p \fIPROGRAM\fR] [\-x \fIFILE\fR] [\fIFILE\fR...]
8b341f8
.HP 7
8b341f8
\fBunprotoize\fR [\-fkNnqv] [\-c \fICOMPILATION-OPTIONS\fR] [\-d \fIDIRECTORY\fR] [\-i \fISTRING\fR] [\-p \fIPROGRAM\fR] [\-x \fIFILE\fR] [\fIFILE\fR...]
8b341f8
.SH DESCRIPTION
8b341f8
.PP
8b341f8
\fBprotoize\fR is an optional part of GCC.
8b341f8
You can use it to add prototypes to a program,
8b341f8
thus converting the program to ANSI C in one respect.
8b341f8
The companion program
8b341f8
\fBunprotoize\fR does the reverse: it removes argument types from any prototypes that are found.
8b341f8
.PP
8b341f8
When you run these programs, you must specify a set of source files
8b341f8
as command line arguments.
8b341f8
The conversion programs start out by compiling these files
8b341f8
to see what functions they define.
8b341f8
The information gathered about a file
8b341f8
\fIFOO\fR is saved in a file named \fIFOO.X\fR.
8b341f8
.PP
8b341f8
After scanning comes the actual conversion.
8b341f8
The specified files are all eligible to be converted;
8b341f8
any files they include (whether sources or just headers) are eligible as well.
8b341f8
.PP
8b341f8
But not all the eligible files are converted.
8b341f8
By default,
8b341f8
\fBprotoize\fR and \fBunprotoize\fR
8b341f8
convert only source and header files in the current directory.
8b341f8
You can specify additional directories whose files
8b341f8
should be converted with the
8b341f8
\fB\-d\fR \fIDIRECTORY\fR option.
8b341f8
You can also specify particular files to exclude with the
8b341f8
\fB\-x\fR \fIFILE\fR option.
8b341f8
A file is converted if it is eligible, its directory name matches one of the
8b341f8
specified directory names, and its name within the directory has not
8b341f8
been excluded.
8b341f8
.PP
8b341f8
Basic conversion with
8b341f8
\fBprotoize\fR consists of rewriting most function definitions and function declarations
8b341f8
to specify the types of the arguments.
8b341f8
The only ones not rewritten are those for varargs functions.
8b341f8
.PP
8b341f8
\fBprotoize\fR optionally inserts prototype declarations at the beginning of the source file,
8b341f8
to make them available for any calls that precede the function's definition.
8b341f8
Or it can insert prototype declarations with block scope
8b341f8
in the blocks where undeclared functions are called.
8b341f8
.PP
8b341f8
Basic conversion with
8b341f8
\fBunprotoize\fR
8b341f8
consists of rewriting most function declarations to remove any argument types,
8b341f8
and rewriting function definitions to the old-style pre-ANSI form.
8b341f8
.PP
8b341f8
Both conversion programs print a warning for any function
8b341f8
declaration or definition that they can't convert.
8b341f8
You can suppress these warnings with the
8b341f8
\fB\-q\fR option.
8b341f8
.PP
8b341f8
The output from
8b341f8
\fBprotoize\fR or \fBunprotoize\fR
8b341f8
replaces the original source file.
8b341f8
The original file is renamed to a name ending with
8b341f8
\fI.save\fR.
8b341f8
If the \fI.save\fR file already exists, then the source file is simply discarded.
8b341f8
.PP
8b341f8
\fBprotoize\fR and \fBunprotoize\fR both depend on
8b341f8
\fBgcc\fR\|(1) to scan the program and collect information about the functions it uses.
8b341f8
.PP
8b341f8
The options are as follows:
8b341f8
.TP
8b341f8
\fB\-B\fR \fIDIRECTORY\fR
8b341f8
Look for the file
8b341f8
\fISYSCALLS.c.X\fR in \fIdirectory\fR,
8b341f8
instead of the usual directory (normally \fI/usr/local/lib\fR).
8b341f8
This file contains prototype information about standard system functions.
8b341f8
This option applies only to \fBprotoize\fR.
8b341f8
.TP
8b341f8
\fB\-C\fR
8b341f8
Rename files to end in
8b341f8
\fI.C\fR instead of \fI.c\fR.
8b341f8
This is convenient if you are converting a C program to C++.
8b341f8
This option applies only to
8b341f8
\fBprotoize\fR.
8b341f8
.TP
8b341f8
\fB\-c\fR \fICOMPILATION-OPTIONS\fR
8b341f8
Use \fICOMPILATION-OPTIONS\fR as the options when running \fBgcc\fR\|(1) to produce the
8b341f8
\fI.X\fR files.
8b341f8
The special option \fB\-aux-info\fR is always passed in addition, to tell gcc to write a
8b341f8
\fI.X\fR file.
8b341f8
Note that the compilation options must be given as a single argument to
8b341f8
\fBprotoize\fR or \fBunprotoize\fR.
8b341f8
If you want to specify several gcc options, you must quote the entire set of
8b341f8
compilation options to make them a single word in the shell.
8b341f8
There are certain gcc arguments that you cannot use, because they
8b341f8
would produce the wrong kind of output.
8b341f8
These include
8b341f8
\fB\-g\fR, \fB\-O\fR, \fB\-c\fR, \fB\-S\fR,\fB\-o\fR.
8b341f8
If you include these in the \fICOMPILATION-OPTIONS\fR, they are ignored.
8b341f8
.TP
8b341f8
\fB\-d\fR \fIDIRECTORY\fR
8b341f8
Specify additional directories whose files should be converted.
8b341f8
.TP
8b341f8
\fB\-g\fR
8b341f8
Add explicit global declarations.
8b341f8
This means inserting explicit declarations at the beginning of each
8b341f8
source file for each function that is called in the file and was not declared.
8b341f8
These declarations precede the first function definition that contains a
8b341f8
call to an undeclared function.
8b341f8
This option applies only to
8b341f8
.\fBprotoize\fR.
8b341f8
.TP
8b341f8
\fB\-i\fR \fISTRING\fR
8b341f8
Indent old-style parameter declarations with the string
8b341f8
\fISTRING\fR.
8b341f8
This option applies only to
8b341f8
\fBprotoize\fR.
8b341f8
\fBunprotoize\fR converts prototyped function definitions to old-style
8b341f8
function definitions, where the arguments are declared between the
8b341f8
argument list and the initial
8b341f8
\fB{\fR.
8b341f8
By default,
8b341f8
\fBunprotoize\fR uses five spaces as the indentation.
8b341f8
If you want to indent with just one space instead, use
8b341f8
\fB\-i " "\fR.
8b341f8
.TP
8b341f8
\fB\-k\fR
8b341f8
Keep the
8b341f8
\fI.X\fR files.
8b341f8
Normally, they are deleted after conversion is finished.
8b341f8
.TP
8b341f8
\fB\-l\fR
8b341f8
Add explicit local declarations.
8b341f8
\fBprotoize\fR with
8b341f8
\fB\-l\fR inserts a prototype declaration for each function in each block which calls
8b341f8
the function without any declaration.
8b341f8
This option applies only to
8b341f8
\fBprotoize\fR.
8b341f8
.TP
8b341f8
\fB\-N\fR
8b341f8
Make no \fI.save\fR files.
8b341f8
The original files are simply deleted.
8b341f8
Use this option with caution.
8b341f8
.TP
8b341f8
\fB\-n\fR
8b341f8
Make no real changes.
8b341f8
This mode just prints information about the conversions
8b341f8
that would have been done without
8b341f8
\fB\-n\fR.
8b341f8
.TP
8b341f8
\fB\-p\fR \fIPROGRAM\fR
8b341f8
Use the program
8b341f8
\fBPROGRAM\fR as the compiler.
8b341f8
Normally, the name
8b341f8
\fBgcc\fR is used.
8b341f8
.TP
8b341f8
\fB\-q\fR
8b341f8
Work quietly.
8b341f8
Most warnings are suppressed.
8b341f8
.TP
8b341f8
\fB\-v\fR
8b341f8
Print the version number, just like
8b341f8
\fB\-v\fR for gcc.
8b341f8
.TP
8b341f8
\fB\-x\fR \fBFILE\fR
8b341f8
List of files to exclude from the conversion process.
8b341f8
.PP
8b341f8
If you need special compiler options to compile one of your program's
8b341f8
source files, then you should generate that file's
8b341f8
\fI.X\fR file specially, by running gcc on that source file with
8b341f8
the appropriate options and the option
8b341f8
\fB\-aux-info\fR.
8b341f8
Then run
8b341f8
\fBprotoize\fR on the entire set of files.
8b341f8
\fBprotoize\fR will use the existing
8b341f8
\fI.X\fR file because it is newer than the source file.
8b341f8
For example:
8b341f8
.PP
8b341f8
.DL $ gcc -Dfoo=bar file1.c -aux-info
8b341f8
.DL $ protoize *.c
8b341f8
.PP
8b341f8
You need to include the special files along with the rest in the
8b341f8
\fBprotoize\fR command, even though their
8b341f8
\fI.X\fR files already exist, because otherwise they won't get converted.
8b341f8
.PP
8b341f8
.SH SEE ALSO
8b341f8
\fBgcc\fR\|(1), and the Info entry for \fBgcc\fR, particularly
8b341f8
\fBRunning protoize\fR section.
8b341f8
.SH HISTORY
8b341f8
Ron Guilmette implemented the
8b341f8
\fBprotoize\fR and \fBunprotoize\fR tools.
8b341f8
.SH AUTHORS
8b341f8
See the GCC manual for the contributors to GCC.
8b341f8
.SH CAVEATS
8b341f8
The conversion programs \fBprotoize\fR and \fBunprotoize\fR
8b341f8
can sometimes change a source file in a way that won't work
8b341f8
unless you rearrange it.
8b341f8
.PP
8b341f8
\fBprotoize\fR can insert references to a type name or type tag before
8b341f8
the definition, or in a file where they are not defined.
8b341f8
.PP
8b341f8
If this happens, compiler error messages should indicate where the
8b341f8
new references are, so fixing the file by hand is straightforward.
8b341f8
.PP
8b341f8
There are some C constructs which \fBprotoize\fR
8b341f8
cannot figure out.
8b341f8
For example, it can't determine argument types for declaring a
8b341f8
pointer-to-function variable; this must be done by hand.  \fBprotoize\fR
8b341f8
inserts a comment containing \fB???\fR each time it finds such a variable;
8b341f8
all such variables can be found by searching for this string.
8b341f8
ANSI C does not require declaring the argument types of
8b341f8
pointer-to-function types.
8b341f8
.PP
8b341f8
Using \fBunprotoize\fR can easily introduce bugs.
8b341f8
If the program relied on prototypes to bring about conversion of arguments,
8b341f8
these conversions will not take place in the program without prototypes.
8b341f8
One case in which you can be sure \fBunprotoize\fR
8b341f8
is safe is when you are removing prototypes that were made with
8b341f8
\fBprotoize\fR; if the program worked before without any prototypes,
8b341f8
it will work again without them.
8b341f8
.PP
8b341f8
You can find all the places where this problem might occur by
8b341f8
compiling the program with the \fB\-Wconversion\fR option.
8b341f8
It prints a warning whenever an argument is converted.
8b341f8
.PP
8b341f8
Both conversion programs can be confused if there are macro calls
8b341f8
in and around the text to be converted.
8b341f8
In other words, the standard syntax for a declaration or definition
8b341f8
must not result from expanding a macro.
8b341f8
This problem is inherent in the design of C and cannot be fixed.
8b341f8
If only a few functions have confusing macro calls,
8b341f8
you can easily convert them manually.
8b341f8
.PP
8b341f8
\fBprotoize\fR cannot get the argument types for a function whose definition was not
8b341f8
actually compiled due to preprocessing conditionals.
8b341f8
When this happens, \fBprotoize\fR changes nothing in regard to such a function.
8b341f8
\fBprotoize\fR tries to detect such instances and warn about them.
8b341f8
.PP
8b341f8
You can generally work around this problem by using
8b341f8
\fBprotoize\fR step by step, each time specifying a different set of
8b341f8
\fB\-D\fR options for compilation, until all of the functions have been converted.
8b341f8
There is no automatic way to verify that you have got them all, however.
8b341f8
.PP
8b341f8
Confusion may result if there is an occasion to convert a function
8b341f8
declaration or definition in a region of source code where there
8b341f8
is more than one formal parameter list present.
8b341f8
Thus, attempts to convert code containing multiple (conditionally compiled)
8b341f8
versions of a single function header (in the same vicinity)
8b341f8
may not produce the desired (or expected) results.
8b341f8
.PP
8b341f8
If you plan on converting source files which contain such code,
8b341f8
it is recommended that you first make sure that each conditionally
8b341f8
compiled region of source code which contains an alternative
8b341f8
function header also contains at least one additional follower
8b341f8
token (past the final right parenthesis of the function header).
8b341f8
This should circumvent the problem.
8b341f8
.PP
8b341f8
\fBunprotoize\fR can become confused when trying to convert a function
8b341f8
definition or declaration which contains a declaration for a
8b341f8
pointer-to-function formal argument which has the same name as the
8b341f8
function being defined or declared.
8b341f8
We recommand you avoid such choices of formal parameter names.
8b341f8
.PP
8b341f8
It might be necessary to correct some of the indentation by hand and
8b341f8
break long lines.
8b341f8
(The conversion programs don't write lines longer than eighty characters
8b341f8
in any case.)
8b341f8
.SH BUGS
8b341f8
For instructions on reporting bugs, see the GCC manual.
8b341f8
.SH COPYING
8b341f8
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
8b341f8
2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
8b341f8
.PP
8b341f8
Permission is granted to make and distribute verbatim copies of
8b341f8
this manual provided the copyright notice and this permission notice
8b341f8
are preserved on all copies.
8b341f8
.PP
8b341f8
Permission is granted to copy and distribute modified versions of this
8b341f8
manual under the conditions for verbatim copying, provided that the
8b341f8
entire resulting derived work is distributed under the terms of a
8b341f8
permission notice identical to this one.
8b341f8
.PP
8b341f8
Permission is granted to copy and distribute translations of this
8b341f8
manual into another language, under the above conditions for modified
8b341f8
versions, except that this permission notice may be included in
8b341f8
translations approved by the Free Software Foundation instead of in
8b341f8
the original English.