f78 Running protoize Contents|Index|Previous|Next
 

Running protoize 

The program, protoize, is an optional part of GNU CC. You can use it to add prototypes to a program, thus converting the program to ANSI C in one respect. The companion program, unprotoize, does the reverse: it removes argument types from any prototypes that are found.

When you run these programs, you must specify a set of source files as command line arguments. The conversion programs start out by compiling these files to see what functions they define. The information gathered about a file, foo, is saved in a file named foo.X.

After scanning comes actual conversion. The specified files are all eligible to be converted; any files they include (whether sources or just headers) are eligible as well.

But not all the eligible files are converted. By default, protoize and unprotoize convert only source and header files in the current directory. You can specify additional directories whose files should be converted with the ‘-d’ directory option. You can also specify particular files to exclude with the ‘-x’ file option. A file is converted if it is eligible, its directory name matches one of the specified directory names, and its name within the directory has not been excluded.

Basic conversion with protoize consists of rewriting most function definitions and function declarations to specify the types of the arguments. The only ones not rewritten are those for varargs functions.

protoize op ffb tionally inserts prototype declarations at the beginning of the source file, to make them available for any calls that precede the function’s definition. Or it can insert prototype declarations with block scope in the blocks where undeclared functions are called.

Basic conversion with unprotoize consists of rewriting most function declarations to remove any argument types, and rewriting function definitions to the old-style pre-ANSI form.

Both conversion programs print a warning for any function declaration or definition they can’t convert. You can suppress these warnings with ‘-q’.

The output from protoize or unprotoize replaces the original source file. The original file is renamed to a name ending with .save.  If the .save file already exists, then the source file is simply discarded.

protoize and unprotoize both depend on GNU CC itself to scan the program and collect information about the functions it uses. So neither of these programs will work until GNU CC is installed.

You can use the following options with protoize and unprotoize.  Each option works with both programs unless otherwise stated. 0