HPlogo HP-UX Reference Volume 1 of 5 > c

cc_bundled(1)

Bundled C Compiler - Limited Functionality
» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

cc — bundled C compiler

SYNOPSIS

cc [options] files

DESCRIPTION

This manual page describes the Bundled C compiler. See cc(1), online only, for a description of the ANSI-compliant HP-UX manual page.

This cc accepts several types of arguments as files:

.c Suffix

Arguments whose names end with .c are understood to be C source files. Each is compiled and the resulting object file is left in a file having the corresponding base name, .o instead of .c. However, if a single C file is compiled and linked, all in one step, the .o file is deleted.

.s Suffix

Arguments whose names end with .s are understood to be assembly source files and are assembled, producing a .o file for each .s file.

.i Suffix

Arguments whose names end with .i are assumed to be the output of cpp (see the -P option below). They are compiled without invoking cpp (see cpp(1)). Each object file is left in a file having the corresponding base name, but suffixed with .o instead of .i.

-lx Form

Arguments of the form -lx cause the linker to search the library libx.sl or libx.a in an attempt to resolve currently unresolved external references. Because a library is searched when its name is encountered, placement of a -l is significant. If a file contains an unresolved external reference, the library containing the definition must be placed after the file on the command line. See ld(1) for further details.

-l:libx.suffix Form

Arguments of the form -l:libx.suffix cause the linker to search the library libx.sl or libx.a (depending on suffix) in an attempt to resolve currently unresolved external references. It is similar to the -l option except the current state of the -Wl,-a option is not important.

Other Suffixes

All other arguments, such as those whose names end with .o or .a, are taken to be relocatable object files that are to be included in the link operation.

Arguments and options can be passed to the compiler through the CCOPTS environment variable as well as on the command line. The compiler reads the value of CCOPTS and divides these options into two sets; options that appear before a vertical bar (|), and options that appear after the vertical bar. The first set of options are placed before any of the command-line parameters to cc; the second set of options are placed after the command-line parameters to cc. If the vertical bar is not present, all options are placed before the command-line parameters. For example (in sh(1) notation),

CCOPTS="-v | -lmalloc" export CCOPTS cc -w prog.c

is equivalent to

cc -v -w prog.c -lmalloc

When set, the TMPDIR environment variable specifies a directory to be used by the compiler for temporary files, overriding the default directory /var/tmp.

Options

The following options are the only options which are recognized by the bundled C compiler.

-c

Suppress the link edit phase of the compilation, and force an object (.o) file to be produced for each .c file, even if only one program is compiled. Object files produced from C programs must be linked before being executed.

-C

Prevent the preprocessor from stripping C-style comments. See cpp(1) for details.

-Dname=def

Define name to the preprocessor, as if by '#define'. See cpp(1) for details.

-Dname

-E

Run only cpp on the named C or assembly files, and send the result to the standard output.

-Idir

Change the algorithm used by the preprocessor for finding include files to also search in directory dir. See cpp(1) for details.

-lx

Refer to the DESCRIPTION section.

-L dir

Change the algorithm used by the linker to search for libx.sl or libx.a. The -L option causes cc to search in dir before searching in the default locations. See ld(1) for details.

-ooutfile

Name the output file from the linker outfile. The default name is a.out.

-P

Run only cpp on the named C files and leave the result on corresponding files suffixed .i. The -P option is also passed along to cpp.

+Rnum

Allow only the first num register variables to actually have the register class. Use this option when the register allocator issues the message:

out of general registers

-s

Cause the output of the linker to be stripped of symbol table information. See strip(1) for more details. The use of this option prevents the use of a symbolic debugger on the resulting program. See ld(1) for more details.

-S

Compile the named C files, and leave the assembly language output on corresponding files suffixed .s.

-tx,name

Substitute subprocess x with name where x is one or more of a set of identifiers indicating the subprocess(es). This option works in two modes: 1) if x is a single identifier, name represents the full path name of the new subprocess; 2) if x is a set of identifiers, name represents a prefix to which the standard suffixes are concatenated to construct the full path names of the new subprocesses.

The x can take one or more of the values:

p

Preprocessor (standard suffix is cpp)

c

Compiler (standard suffix is ccom)

a

Assembler (standard suffix is as)

l

Linker (standard suffix is ld)

-Uname

Remove any initial definition of name in the preprocessor. See cpp(1) for details.

-v

Enable verbose mode, which produces a step-by-step description of the compilation process on the standard error.

-V

Cause each invoked subprocess to print its version information to stdout.

-w

Suppress warning messages.

-Wx,arglist

Pass the comma-separated argument(s) in arglist to subprocess x. The -W option specification allows additional, implementation-specific options to be recognized by the compiler driver. For example,

-Wl,-a,archive

causes the linker to link with archive libraries instead of with shared libraries. See ld(1) for details.

The x can assume one of the following values:

p

Preprocessor

a

Assembler

l

Linker

Any other options encountered generate a warning to standard error.

Other arguments are assumed to be C-compatible object programs, typically produced by an earlier cc run, or perhaps libraries of C-compatible routines. These programs, together with the results of any compilations specified, are linked (in the order given) to produce an executable program with the name a.out.

EXTERNAL INFLUENCES

Environment Variables

LANG determines the language in which messages are displayed.

If LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of C (see lang(5)) is used. If any internationalization variable contains an invalid setting, cc behaves as if all internationalization variables are set to C. See environ(5).

International Code Set Support

Single byte and multibyte character code sets are supported.

DIAGNOSTICS

The diagnostics produced by C itself are intended to be self-explanatory. Occasionally, messages may be produced by the preprocessor, assembler, or the link editor.

If any errors occur before cc is completed, a nonzero value is returned. Otherwise, zero is returned.

EXAMPLES

The example below compiles the C file prog.c to create a prog.o file, then invokes the ld link editor to link prog.o and procedure.o with all of the C startup routines in /usr/ccs/lib/crt0.o and library routines from the C library libc.sl or libc.a. The resulting executable program is placed in file prog:

cc prog.c procedure.o -o prog

WARNINGS

Options not recognized by cc are not passed on to the link editor. The option -Wl,arg can be used to pass any such option to the link editor.

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

FILES

file.c

Input file

file.o

Object file

a.out

Linked executable output file

/var/tmp/ctm*

Temporary files used by the compiler

/usr/ccs/bin/as

Assembler (see as(1))

/usr/ccs/bin/ld

Link editor (see ld(1))

/usr/ccs/lib/crt0.o

Runtime startup

/usr/lib/libc.a

Standard C library (archive version), see HP-UX Reference Section (3)

/usr/lib/libc.sl

Standard C library (shared version), see HP-UX Reference Section (3)

/usr/include

Standard directory for #include files

Bundled C Compiler Files

/usr/ccs/bin/cc

C driver

/usr/ccs/lbin/ccom

C compiler

/usr/lib/nls/msg/$LANG/cc.cat

C compiler message catalog

/usr/ccs/lbin/cpp

C preprocessor

SEE ALSO

System Tools

as(1)

Translate assembly code to machine code.

cpp(1)

Invoke the C language preprocessor.

ld(1)

Invoke the link editor.

cc(1)

The ANSI-compliant C compiler on HP-UX.

Miscellaneous

matherr(3M)

Trap math errors.

fpgetround(3M)

Floating-point mode control functions.

strip(1)

Strip symbol and line number information from an object file.

crt0(3)

Execution startup routine.

end(3C)

Symbol of the last locations in program.

exit(2)

Termination of a process.

Tutorials and Standards Documents

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

© Hewlett-Packard Development Company, L.P.