home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume28 / cproto / part01 / cproto.man < prev    next >
Text File  |  1992-03-15  |  7KB  |  265 lines

  1.  
  2.  
  3. CPROTO(1)                  Unix Programmer's Manual                  CPROTO(1)
  4.  
  5.  
  6. NAME
  7.      cproto - generate C function prototypes and convert function definitions
  8.  
  9. SYNOPSIS
  10.      cproto [ option ... ] [ file ... ]
  11.  
  12. DESCRIPTION
  13.      Cproto  generates  function  prototypes  for  functions  defined  in  the
  14.      specified   C   source  files  to  the  standard  output.   The  function
  15.      definitions may be in the old style or ANSI C style.  Optionally,  cproto
  16.      also  outputs  declarations for any variables defined in the file.  If no
  17.      file argument is given, cproto reads its input from the standard input.
  18.  
  19.      By giving a command  line  option,  cproto  will  also  convert  function
  20.      definitions  in  the  specified  files  from  the old style to the ANSI C
  21.      style.  The original source files along with files specified by
  22.  
  23.            #include "file"
  24.  
  25.      directives appearing in the source code  will  be  overwritten  with  the
  26.      converted code.  If no file names are given on the command line, then the
  27.      program reads the source code from the standard  input  and  outputs  the
  28.      converted source to the standard output.
  29.  
  30.      If any comments appear in  the  parameter  declarations  for  a  function
  31.      definition, such as in the example,
  32.  
  33.            main (argc, argv)
  34.            int argc;       /* number of arguments */
  35.            char *argv[];   /* arguments */
  36.            {
  37.             ...
  38.            }
  39.  
  40.      then the converted function definition will have the form
  41.  
  42.            int
  43.            main (
  44.                int argc;       /* number of arguments */
  45.                char *argv[];   /* arguments */
  46.            )
  47.            {
  48.             ...
  49.            }
  50.  
  51.      Otherwise, the converted function definition will look like
  52.  
  53.            int
  54.            main (int argc, char *argv[])
  55.            {
  56.             ...
  57.            }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.                                 March 6, 1992                                1
  65.  
  66.  
  67.  
  68.  
  69. CPROTO(1)                  Unix Programmer's Manual                  CPROTO(1)
  70.  
  71.  
  72.      Cproto can optionally convert function definitions from the ANSI style to
  73.      the  old  style.   In  this  mode,  the  program  also  converts function
  74.      declarators and prototypes that appear outside function bodies.  This  is
  75.      not  a  complete ANSI C to old C conversion.  The program does not change
  76.      anything within function bodies.
  77.  
  78. OPTIONS
  79.  
  80.      -a   Convert function definitions from the old style to the ANSI C style.
  81.  
  82.      -e   Output the keyword extern  in  front  of  every  declaration  having
  83.           global scope.
  84.  
  85.      -fn  Set the style of function prototype where n is a number from 0 to 4.
  86.           For example, consider the function definition
  87.  
  88.                 main (argc, argv)
  89.                 int argc;
  90.                 char *argv[];
  91.                 {
  92.                  ...
  93.                 }
  94.  
  95.           If the value is 0, then no prototypes are generated.  When set to 1,
  96.           the output is:
  97.  
  98.                 int main(/*int argc, char *argv[]*/);
  99.  
  100.           For a value of 2, the output has the form:
  101.  
  102.                 int main(int /*argc*/, char */*argv*/[]);
  103.  
  104.           The default value is 3.  It produces the full function prototype:
  105.  
  106.                 int main(int argc, char *argv[]);
  107.  
  108.           A value of 4 produces prototypes guarded by a macro:
  109.  
  110.                 int main P_((int argc, char *argv[]));
  111.  
  112.  
  113.      -mname
  114.           Set the name of the macro used to guard prototypes when  option  -f4
  115.           is selected.  The default is "P_".
  116.  
  117.      -d   Omit the definition of the prototype macro named by the -m option.
  118.  
  119.      -n   Omit file name comments.  The default is to output the  source  file
  120.           name in a comment before generating the prototypes for that file.
  121.  
  122.      -p   Disable  promotion  of  formal  parameters  in  old  style  function
  123.           definitions.   By  default,  parameters of type char or short in old
  124.           style function definitions are promoted to type int in the  function
  125.           prototype  or  converted  ANSI C function definition.  Parameters of
  126.           type float get promoted to double as well.
  127.  
  128.  
  129.  
  130.                                 March 6, 1992                                2
  131.  
  132.  
  133.  
  134.  
  135. CPROTO(1)                  Unix Programmer's Manual                  CPROTO(1)
  136.  
  137.  
  138.      -s   By default, cproto only generates  declarations  for  functions  and
  139.           variables  having  global  scope.   This  option  will output static
  140.           declarations as well.
  141.  
  142.      -t   Convert  function  definitions  from  the  ANSI  C  style   to   the
  143.           traditional style.
  144.  
  145.      -v   Also output declarations for variables defined in the source.
  146.  
  147.      -Ptemplate
  148.  
  149.      -Ftemplate
  150.  
  151.      -Ctemplate
  152.           Set  the  output   format   for   generated   prototypes,   function
  153.           definitions,   and  function  definitions  with  parameter  comments
  154.           respectively.  The format is specified by a template in the form
  155.  
  156.                 " int main ( a, b )"
  157.  
  158.           but you may replace each space in this string  with  any  number  of
  159.           whitespace characters.  For example, the option
  160.  
  161.                 -F"int main(\n\ta,\n\tb\n\t)"
  162.  
  163.           will produce
  164.  
  165.                 int main(
  166.                         int argc,
  167.                         char *argv[]
  168.                         )
  169.  
  170.  
  171.      -Dname[=value]
  172.           This option is passed through to the preprocessor  and  is  used  to
  173.           define symbols for use with conditionals such as #ifdef.
  174.  
  175.      -Uname
  176.           This option is passed through to the preprocessor  and  is  used  to
  177.           remove any definitions of this symbol.
  178.  
  179.      -Idirectory
  180.           This option is passed through to the preprocessor  and  is  used  to
  181.           specify  a  directory  to  search for files that are referenced with
  182.           #include.
  183.  
  184.      -V   Print version information.
  185.  
  186. ENVIRONMENT
  187.      The environment variable CPROTO is scanned for a list of options  in  the
  188.      same format as the command line options.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.                                 March 6, 1992                                3
  197.  
  198.  
  199.  
  200.  
  201. CPROTO(1)                  Unix Programmer's Manual                  CPROTO(1)
  202.  
  203.  
  204. BUGS
  205.      If an untagged struct, union or enum declaration appears in  a  generated
  206.      function  prototype  or converted function definition, the content of the
  207.      declaration between the braces is empty.
  208.  
  209.      The program does not pipe the source files  through  the  C  preprocessor
  210.      when  it is converting function definitions.  Instead, it tries to handle
  211.      preprocessor directives and macros itself and can be confused  by  tricky
  212.      macro  expansions.   The  conversion  also  discards some comments in the
  213.      function definition head.
  214.  
  215.      When the program encounters an error, it usually  outputs  the  not  very
  216.      descriptive message "syntax error".
  217.  
  218.      Options that take string arguments only interpret the following character
  219.      escape sequences:
  220.  
  221.            \n   newline
  222.            \t   tab
  223.  
  224.  
  225. AUTHOR
  226.      Chin Huang
  227.      cthuang@zerosan.UUCP
  228.      chin.huang@canrem.com
  229.  
  230. SEE ALSO
  231.      cc(1), cpp(1)
  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.                                 March 6, 1992                                4
  263.  
  264.  
  265.