⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 running-protoize.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Using the GNU Compiler Collection (GCC)</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Using the GNU Compiler Collection (GCC)">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

<!--

Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,

1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.



   <p>Permission is granted to copy, distribute and/or modify this document

under the terms of the GNU Free Documentation License, Version 1.2 or

any later version published by the Free Software Foundation; with the

Invariant Sections being "GNU General Public License" and "Funding

Free Software", the Front-Cover texts being (a) (see below), and with

the Back-Cover Texts being (b) (see below).  A copy of the license is

included in the section entitled "GNU Free Documentation License".



   <p>(a) The FSF's Front-Cover Text is:



   <p>A GNU Manual



   <p>(b) The FSF's Back-Cover Text is:



   <p>You have freedom to copy and modify this GNU Manual, like GNU

     software.  Copies published by the Free Software Foundation raise

     funds for GNU development.-->

</head>

<body>

<div class="node">

<p>

Node:<a name="Running%20Protoize">Running Protoize</a>,

Previous:<a rel="previous" accesskey="p" href="Environment-Variables.html#Environment%20Variables">Environment Variables</a>,

Up:<a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking%20GCC">Invoking GCC</a>

<hr><br>

</div>



<h3 class="section">Running Protoize</h3>



   <p>The program <code>protoize</code> is an optional part of GCC.  You can use

it to add prototypes to a program, thus converting the program to ISO

C in one respect.  The companion program <code>unprotoize</code> does the

reverse: it removes argument types from any prototypes that are found.



   <p>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 <var>foo</var> is saved in a file named <code></code><var>foo</var><code>.X</code>.



   <p>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.



   <p>But not all the eligible files are converted.  By default,

<code>protoize</code> and <code>unprotoize</code> convert only source and header

files in the current directory.  You can specify additional directories

whose files should be converted with the <code>-d </code><var>directory</var><code></code>

option.  You can also specify particular files to exclude with the

<code>-x </code><var>file</var><code></code> 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.



   <p>Basic conversion with <code>protoize</code> 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.



   <p><code>protoize</code> optionally 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.



   <p>Basic conversion with <code>unprotoize</code> consists of rewriting most

function declarations to remove any argument types, and rewriting

function definitions to the old-style pre-ISO form.



   <p>Both conversion programs print a warning for any function declaration or

definition that they can't convert.  You can suppress these warnings

with <code>-q</code>.



   <p>The output from <code>protoize</code> or <code>unprotoize</code> replaces the

original source file.  The original file is renamed to a name ending

with <code>.save</code> (for DOS, the saved filename ends in <code>.sav</code>

without the original <code>.c</code> suffix).  If the <code>.save</code> (<code>.sav</code>

for DOS) file already exists, then the source file is simply discarded.



   <p><code>protoize</code> and <code>unprotoize</code> both depend on GCC itself to

scan the program and collect information about the functions it uses. 

So neither of these programs will work until GCC is installed.



   <p>Here is a table of the options you can use with <code>protoize</code> and

<code>unprotoize</code>.  Each option works with both programs unless

otherwise stated.



     <dl>

<dt><code>-B </code><var>directory</var><code></code>

     <dd>Look for the file <code>SYSCALLS.c.X</code> in <var>directory</var>, instead of the

usual directory (normally <code>/usr/local/lib</code>).  This file contains

prototype information about standard system functions.  This option

applies only to <code>protoize</code>.



     <br><dt><code>-c </code><var>compilation-options</var><code></code>

     <dd>Use <var>compilation-options</var> as the options when running <code>gcc</code> to

produce the <code>.X</code> files.  The special option <code>-aux-info</code> is

always passed in addition, to tell <code>gcc</code> to write a <code>.X</code> file.



     <p>Note that the compilation options must be given as a single argument to

<code>protoize</code> or <code>unprotoize</code>.  If you want to specify several

<code>gcc</code> options, you must quote the entire set of compilation options

to make them a single word in the shell.



     <p>There are certain <code>gcc</code> arguments that you cannot use, because they

would produce the wrong kind of output.  These include <code>-g</code>,

<code>-O</code>, <code>-c</code>, <code>-S</code>, and <code>-o</code> If you include these in

the <var>compilation-options</var>, they are ignored.



     <br><dt><code>-C</code>

     <dd>Rename files to end in <code>.C</code> (<code>.cc</code> for DOS-based file

systems) instead of <code>.c</code>.  This is convenient if you are converting

a C program to C++.  This option applies only to <code>protoize</code>.



     <br><dt><code>-g</code>

     <dd>Add explicit global declarations.  This means inserting explicit

declarations at the beginning of each source file for each function

that is called in the file and was not declared.  These declarations

precede the first function definition that contains a call to an

undeclared function.  This option applies only to <code>protoize</code>.



     <br><dt><code>-i </code><var>string</var><code></code>

     <dd>Indent old-style parameter declarations with the string <var>string</var>. 

This option applies only to <code>protoize</code>.



     <p><code>unprotoize</code> converts prototyped function definitions to old-style

function definitions, where the arguments are declared between the

argument list and the initial <code>{</code>.  By default, <code>unprotoize</code>

uses five spaces as the indentation.  If you want to indent with just

one space instead, use <code>-i " "</code>.



     <br><dt><code>-k</code>

     <dd>Keep the <code>.X</code> files.  Normally, they are deleted after conversion

is finished.



     <br><dt><code>-l</code>

     <dd>Add explicit local declarations.  <code>protoize</code> with <code>-l</code> inserts

a prototype declaration for each function in each block which calls the

function without any declaration.  This option applies only to

<code>protoize</code>.



     <br><dt><code>-n</code>

     <dd>Make no real changes.  This mode just prints information about the conversions

that would have been done without <code>-n</code>.



     <br><dt><code>-N</code>

     <dd>Make no <code>.save</code> files.  The original files are simply deleted. 

Use this option with caution.



     <br><dt><code>-p </code><var>program</var><code></code>

     <dd>Use the program <var>program</var> as the compiler.  Normally, the name

<code>gcc</code> is used.



     <br><dt><code>-q</code>

     <dd>Work quietly.  Most warnings are suppressed.



     <br><dt><code>-v</code>

     <dd>Print the version number, just like <code>-v</code> for <code>gcc</code>. 

</dl>



   <p>If you need special compiler options to compile one of your program's

source files, then you should generate that file's <code>.X</code> file

specially, by running <code>gcc</code> on that source file with the

appropriate options and the option <code>-aux-info</code>.  Then run

<code>protoize</code> on the entire set of files.  <code>protoize</code> will use

the existing <code>.X</code> file because it is newer than the source file. 

For example:



<pre class="example">     gcc -Dfoo=bar file1.c -aux-info file1.X

     protoize *.c

     </pre>



<p>You need to include the special files along with the rest in the

<code>protoize</code> command, even though their <code>.X</code> files already

exist, because otherwise they won't get converted.



   <p>See <a href="Protoize-Caveats.html#Protoize%20Caveats">Protoize Caveats</a>, for more information on how to use

<code>protoize</code> successfully.



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -