Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acc(1)

cc(1)

cpp(1)



  cproto(1)                           CLIX                           cproto(1)



  NAME

    cproto - Generates C function prototypes and converts function definitions

  SYNOPSIS

    cproto [flag...] [file...]

  FLAGS

    -a           Converts function definitions to the ANSI C style.

    -e           Prints the keyword extern in front of every declaration
                 having global scope.

    -fn          Sets the style of generated function prototypes where n is a
                 number from 0 to 4.  The values of n and their meanings are
                 as follows:

                 0   Does not generate any prototypes.

                 1

                 2   Produces abbreviated prototypes.

                 3   Produces the full function prototype.  This is the
                     default.

                 4   Produces prototypes guarded by a macro.

                 The following is a function definition:

                 main (argc, argv)
                 int argc;
                 char *argv[];
                 {


                  ...


                 }


                 If the value of n is 0, then no prototypes are generated.
                 When set to 1, the output has this form:

                 int main(/*int argc, char *argv[]*/);


                 When n is set to 2, the output has the following form:



  2/94 - Intergraph Corporation                                              1






  cproto(1)                           CLIX                           cproto(1)



                 int main(int /*argc*/, char */*argv*/[]);


                 When n is 3 (the default value), it produces the full
                 function prototype as shown:

                 int main(int argc, char *argv[]);


                 When n has a value of 4, a prototype guarded by a macro is
                 produced:

                 int main P_((int argc, char *argv[]));


    -c           Omits the parameter comments in the prototypes generated by
                 the -f1 and -f2 flags.  This flag also omits the comments
                 naming the source files from which the prototypes were
                 generated.

    -m name      Sets the name of the macro used to guard prototypes when the
                 -f4 flag is selected.  The default is P_.

    -d           Omits the definition of the prototype macro named by the -m
                 flag.

    -p           Disables the promotion of formal parameters in old style
                 function definitions.  By default, parameters of type char or
                 short in old style function definitions are promoted to type
                 int in the function prototype or converted ANSI C function
                 definition.  Parameters of type float are promoted to double
                 as well.

    -s           Prints static declarations.  By default, cproto only
                 generates declarations for functions and variables having
                 global scope.  This flag prints static declarations as well.

    -t           Converts function definitions from the ANSI C style to the
                 traditional style C.

    -v           Prints declarations for variables defined in the source.

    -Ptemplate   Sets the output format for generated prototypes.

    -Ftemplate   Sets the output format for function definitions.

    -Ctemplate   Sets the output format for function definitions with
                 parameter comments.

                 For the -P, -F, and -C flags, the format is specified by a
                 template in the following form:



  2                                              Intergraph Corporation - 2/94






  cproto(1)                           CLIX                           cproto(1)



                 " int main ( a, b )"


                 Each space in this string may be replaced with any number of
                 whitespace characters.  For example, the -F flag is used in
                 this manner:

                 -F"int main(\n\ta,\n\tb\n\t)"


                 This flag will produce the following output:

                 int main(
                      int argc,
                      char *argv[]
                      )


    -Dname[=value]
                 Passes through to the preprocessor and defines symbols for
                 use with conditionals such as #ifdef.

    -Uname       Passes through to the preprocessor and removes any
                 definitions of the named symbol.

    -I directory Passes through to the preprocessor and specifies a directory
                 to search for files that are referenced with #include
                 statements.

    -V           Prints version information.

  DESCRIPTION

    The cproto generates function prototypes for functions defined in the
    specified C source files to stdout.  The function definitions may be in
    the old style or ANSI C style.  Optionally, cproto also prints
    declarations for any variables defined in the file.  If no file is given,
    cproto reads its input from stdin.

    With certain command-line flags, cproto also converts function definitions
    in the specified files from the old style to the ANSI C style.  The
    original source files along with files specified by #include "file"
    directives appearing in the source code will be overwritten with the
    converted code.  If no file names are given on the command line, then the
    program reads the source code from stdin and prints the converted source
    to stdout.

    The following example has comments appearing in the parameter declarations
    for a function definitions.

    main (argc, argv)



  2/94 - Intergraph Corporation                                              3






  cproto(1)                           CLIX                           cproto(1)



    int argc; /* number of arguments */
    char *argv[];  /* arguments */
    {


     ...


    }


    The converted function definition will have this form:

    int
    main (
        int argc;      /* number of arguments */
        char *argv[];   /* arguments */
    )
    {


     ...


    }


    If the original function does not have comments in the parameter
    declarations, this is how the converted function definition will appear:

    int
    main (int argc, char *argv[])
    {


     ...


    }


    The cproto command can convert function definitions from the ANSI C style
    to the old style C.  In this mode, the program also converts function
    declarators and prototypes that appear outside function bodies.  This is
    not a complete ANSI C to old C conversion.  The program does not change
    anything within function bodies.

    The environment variable CPROTO is scanned for a list of options in the
    same format as the command line flags.

  CAUTIONS



  4                                              Intergraph Corporation - 2/94






  cproto(1)                           CLIX                           cproto(1)



    If an untagged struct, union or enum declaration appears in a generated
    function prototype or converted function definition, the content of the
    declaration between the braces is empty.

    The program does not pipe the source files through the C preprocessor when
    it is converting function definitions.  Instead, it tries to handle
    preprocessor directives and macros itself and can be confused by tricky
    macro expansions.  The conversion also discards some comments in the
    function definition head.

    The -v flag does not generate declarations for variables defined with the
    extern specifier.  This does not strictly conform to the C language
    standard, but this rule was implemented because include files commonly
    declare variables this way.

    When the program encounters an error, it usually prints the not very
    descriptive message syntax error.

    Flags that take string arguments only interpret the following character
    escape sequences:

    0    Newline


         Tab

  EXIT VALUES

    The cproto command returns a value of 0 if successful.  If unsuccessful,
    it returns a value of 1.  The value of 1 is returned for any error;  there
    are no specific exit values for particular kinds of errors.

  RELATED INFORMATION

    Commands:  acc(1), cc(1), cpp(1)



















  2/94 - Intergraph Corporation                                              5




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026