Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

as(1)

cpp(1)

gencc(1M)

ld(1)

lint(1)

prof(1)

sdb(1)

tmpnam(3S)

cc(1)



          cc(1)                INTERACTIVE UNIX System                cc(1)



          NAME
               cc - C compiler

          SYNOPSIS
               cc [ options ] files

          DESCRIPTION
               The cc command is the interface to the C Compilation System.
               The compilation tools consist of a preprocessor, compiler,
               optimizer, assembler, and link editor.  The cc command
               processes the supplied options and then executes the various
               tools with the proper arguments.  The cc command accepts
               several types of files as arguments.

               Files whose names end with .c are taken to be C source pro-
               grams and may be preprocessed, compiled, optimized, assem-
               bled, and link edited.  The compilation process may be
               stopped after the completion of any pass if the appropriate
               options are supplied.  If the compilation process runs
               through the assembler, then an object program is produced
               and is left in the file whose name is that of the source
               with .o substituted for .c.  However, the .o file is nor-
               mally deleted if a single C program is compiled and then
               immediately link edited.  In the same way, files whose names
               end in .s are taken to be assembly source programs and may
               be assembled and link edited, and files whose names end in
               .i are taken to be preprocessed C source programs and may be
               compiled, optimized, assembled, and link edited.  Files
               whose names do not end in .c, .s, or .i are handed to the
               link editor.

               The C compiler also recognizes the environment variable
               OSTYPE.  This environment variable sets the default for the
               compilation environment.  The variable can be set to POSIX,
               to SVR3, or it can be unset.  If it is set to POSIX, the
               compiler will behave as if the -Xp option was set on the
               command line.  If it is set to SVR3, the compiler will
               behave as if the -Xs option was set on the command line.  If
               it is unset, the compiler will behave as if the option was
               set to SVR3.  To set the environment variable using the
               Bourne shell, sh, type:

                    $ OSTYPE=POSIX
                    $ export OSTYPE

               To set the environment variable using the C shell, csh,
               type:

                    setenv OSTYPE POSIX

               Since the cc command usually creates files in the current
               directory during the compilation process, it is necessary to
               run the cc command in a directory in which a file can be


          Rev. 1.2                                                   Page 1





          cc(1)                INTERACTIVE UNIX System                cc(1)



               created.

               The following options are interpreted by cc:

               -c   Suppress the link editing phase of the compilation and
                    do not remove any produced object files.

               -ds  Do not generate symbol attribute information for the
                    symbolic debugger.

               -dl  Do not generate symbolic debugging line number informa-
                    tion.  This and the above flag may be used in conjunc-
                    tion as -dsl (-dsl is the default unless the -g flag is
                    given).

               -g   Cause the compiler to generate additional information
                    needed for the use of sdb(1).

               -o outfile
                    Produce an output object file by the name outfile.  The
                    name of the default file is a.out.  This is a link edi-
                    tor option.

               -p   Arrange for the compiler to produce code that counts
                    the number of times each routine is called; also, if
                    link editing takes place, profiled versions of libc.a
                    and libm.a (with -lm option) are linked and monitor(3C)
                    is automatically called.  A mon.out file will then be
                    produced at normal termination of execution of the
                    object program.  An execution profile can then be gen-
                    erated by use of prof(1).

               -qp  Arrange for profiled code to be produced where the p
                    argument produces identical results to the -p option
                    (allows profiling with prof(1)).

               -E   Run only cpp(1) on the named C programs, and send the
                    result to the standard output.

               -H   Print out on stderr the path name of each file included
                    during the current compilation.

               -O   Do compilation phase optimization. This option will not
                    have any effect on .s files.

               -P   Run only cpp(1) on the named C programs and leave the
                    result in corresponding files suffixed .i.  This option
                    is passed to cpp(1).

               -S   Compile and do not assemble the named C programs, and
                    leave the assembler-language output in corresponding
                    files suffixed .s.



          Rev. 1.2                                                   Page 2





          cc(1)                INTERACTIVE UNIX System                cc(1)



               -V   Print the version of the compiler, optimizer, assem-
                    bler, and/or link editor that is invoked.

               -Wc,arg1[,arg2...]
                    Hand off the argument(s) argi to pass c where c is one
                    of [p02al] indicating the preprocessor, compiler,
                    optimizer, assembler, or link editor, respectively.
                    For example:  -Wa,-m passes -m to the assembler.

               -Xp  Compile for the POSIX environment.  This option causes
                    the correct C startup routines and the libcposix.a
                    library to be linked with the object.

               -Xs  Compile for the System V environment.  This is the
                    default unless the environment variable OSTYPE is set
                    to POSIX.

               -Y [p02alSILU],dirname
                    Specify a new path name, dirname, for the locations of
                    the tools and directories designated in the first argu-
                    ment.  [p02alSILU] represents:
                    p   preprocessor
                    0   compiler
                    2   optimizer
                    a   assembler
                    l   link editor
                    S   directory containing the startup routines
                    I   default include directory searched by cpp(1)
                    L   first default library directory searched by ld(1)
                    U   second default library directory searched by ld(1)

                    If the location of a tool is being specified, then the
                    new path name for the tool will be dirname/tool.  If
                    more than one -Y option is applied to any one tool or
                    directory, then the last occurrence holds.

               -Zp[1|2|4]
                    Packs structure members in memory. Normally, structure
                    members are aligned as follows:  items of type char are
                    byte-aligned, items of type short are aligned on two-
                    byte boundaries, and all other types of structure
                    members are word-aligned.

                    Specifying an option to -Zp will force alignment on the
                    given byte boundary. If no option is used with -Zp,
                    structure members will be packed on one-byte boun-
                    daries. The alignment may be altered with the pragma
                    pack preprocessor directive.

               The cc command also recognizes -C, -D, -I, and -U and passes
               these options and their arguments directly to the preproces-
               sor without using the -W option. Similarly, the cc command
               recognizes -a, -l, -m, -r, -s, -t, -u, -x, -z, -L, -M, and


          Rev. 1.2                                                   Page 3





          cc(1)                INTERACTIVE UNIX System                cc(1)



               -V and passes these options and their arguments directly to
               the loader.  See cpp(1) and ld(1) for descriptions.

               Other arguments are taken to be C compatible object pro-
               grams, typically produced by an earlier cc run, or perhaps
               libraries of C compatible routines, and they are passed
               directly to the link editor.  These programs, together with
               the results of any compilations specified, are link edited
               (in the order given) to produce an executable program with
               name a.out unless the -o option of the link editor is used.

               If the cc command is put in a file prefixcc the prefix will
               be parsed off the command and used to call the tools, i.e.,
               prefixtool.  For example, OLDcc will call OLDcpp, OLDcomp,
               OLDoptim, OLDas, and OLDld and will link OLDcrt1.o.  There-
               fore, one must be careful when moving the cc command around.
               The prefix will apply to the preprocessor, compiler, optim-
               izer, assembler, link editor, and the startup routines.

               The C language standard was extended to allow arbitrary
               length variable names.  The option pair -Wp,-T -W0,-XT will
               cause cc to truncate arbitrary length variable names.

          FILES
               file.c                   C source file
               file.i                   preprocessed C source file
               file.o                   object file
               file.s                   assembly language file
               a.out                    link edited output
               LIBDIR/*crt1.o           startup routine
               LIBDIR/*crtp1.o          POSIX startup routine
               LIBDIR/crtn.o            startup routine
               TMPDIR/*                 temporary files
               LIBDIR/cpp               preprocessor, cpp(1)
               LIBDIR/comp              compiler
               LIBDIR/optim             optimizer
               BINDIR/as                assembler, as(1)
               BINDIR/ld                link editor, ld(1)
               LIBDIR/libc.a            standard C library
               LIBDIR/libc_s.a          standard C shared library

               LIBDIR is usually /lib.

               BINDIR is usually /bin.

               TMPDIR is usually /usr/tmp but can be redefined by setting
               the environment variable TMPDIR (see tempnam() in
               tmpnam(3S)).

          SEE ALSO
               as(1), cpp(1), gencc(1M), ld(1), lint(1), prof(1), sdb(1),
               tmpnam(3S).



          Rev. 1.2                                                   Page 4





          cc(1)                INTERACTIVE UNIX System                cc(1)



               Kernighan, B. W., and Ritchie, D. M., The C Programming
               Language, Prentice-Hall, 1978.

          DIAGNOSTICS
               The diagnostics produced by the C compiler are sometimes
               cryptic.

          NOTES
               By default, the return value from a compiled C program is
               completely random. The only two guaranteed ways to return a
               specific value is to explicitly call exit(2) or to leave the
               function main() with a ``return expression;'' construct.











































          Rev. 1.2                                                   Page 5



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