
protoize Command in Linux
The protoize command in Linux adds prototypes to a program. Adding prototypes means explicitly declaring the function's return type and parameter types before its definition.
Note that the protoize command was an optional part of GCC that allowed adding function prototypes to a program, helping convert it to ANSI C (C89 and later). It was primarily used for updating legacy K&R C codebases but was deprecated in GCC 11 and removed in GCC 12.
Table of Contents
Here is a comprehensive guide to the options available with the protoize command â
- Syntax of protoize Command
- protoize Command Options
- Examples of of protoize Command in Linux
- Alternative to protoize Command in Linux
Note − K&R-style C is mostly obsolete but remains relevant for maintaining legacy code and understanding historical C programming concepts. Use cproto instead of protoize to convert old-style C functions, as protoize was deprecated in GCC 11 and removed in GCC 12.
Syntax of protoize Command
The syntax of the protoize command in Linux is as follows −
protoize [options] [source_fileâ¦]
In the above syntax, the [options] field is used to specify the command options. The [source_fileâ¦] is used to specify one or more C source code files that need to be processed.
protoize Command Options
The commonly used options of the protoize command are listed below −
Option | Description |
---|---|
-B DIRECTORY | Look for the file SYSCALLS.c.X in the specified directory instead of the usual location. |
-C | Rename files to end in .C instead of .c (useful when converting C to C++). |
-c COMPILATION-OPTIONS | Use specified options when running GCC to produce .X files. |
-d DIRECTORY | Specify additional directories whose files should be converted. |
-g | Add explicit global declarations for undeclared function calls. |
-i STRING | Indent old-style parameter declarations using the specified string. |
-k | Keep the .X files instead of deleting them after conversion. |
-l | Add explicit local declarations for function calls without a declaration. |
-N | Do not create .save files; original files are deleted. |
-n | Perform a dry run, showing what changes would be made without applying them. |
-p PROGRAM | Use the specified compiler instead of the default (normally GCC). |
-q | Suppress most warnings and work quietly. |
-v | Print the version number of protoize. |
-x FILE | Exclude specified files from the conversion process. |
Examples of protoize Command in Linux
This section explains how to use the protoize command in Linux with an example −
Converting the K&R-Style C Function Definitions into ANSI C Prototypes
Since protoize was removed in GCC 12, this example applies to older versions of GCC (before GCC 12) where protoize was available.
The protoize command converts the K&R-Style C function definitions into ANSI C prototypes. K&R-style (Kernighan & Ritchie style) function definitions are an older way of writing functions in C. A C code with a K&R style function definition is shown in the following image −

The add function uses old-style (K&R) syntax. The main function calls add(2, 3) and prints the sum.
Now, execute the protoize command with the C code file −
protoize file.c
The above command modifies the source file in place unless the -n (dry run) option is used.
Note that protoize may not work correctly with complex macros or conditional compilation.
Alternative to protoize Command in Linux
The simple alternative to the protoize command is cproto. It is used to generate function prototypes for C programs and convert old-style (K&R) function definitions to ANSI C style.
If it is not installed, install it on Ubuntu, Raspberry Pi, Kali Linux, Debian, and other Debian-based distributions using the following command −
sudo apt install cproto
To install it on Fedora, use −
sudo dnf install cproto
To verify installation, use the following command −
cproto -V

To convert the K&R C function definitions to modern ANSI C, use the cproto in the following way −
cproto file.c

Note that cproto does not handle as many edge cases as protoize did.
Conclusion
The protoize command was used in older versions of GCC to convert K&R-style C functions into ANSI C prototypes, making code more modern and maintainable. It was primarily useful for updating legacy code but was deprecated in GCC 11 and removed in GCC 12. As an alternative, the cproto tool provides similar functionality and remains available for converting old-style function definitions to ANSI C.