home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: cb Chapter 2
UNIX Commands
Next: Reference: cd
 

cc



cc

 [

options

] 

files

Compile one or more C source files ( file .c ), assembler source files ( file .s ), or preprocessed C source files ( file .i ). cc automatically invokes the link editor ld (unless -c is supplied). In some cases, cc generates an object file having a .o suffix and a corresponding root name. By default, output is placed in a.out . cc accepts additional system-specific options. Note: This command runs the ANSI C compiler; use /usr/bin/cc if you want to run the compiler for Kernighan and Ritchie's C.

Options

-#

Show when each compiler tool is invoked. Solaris 2.0 only.

-A name [ ( tokens )]

Supply an #assert directive, assigning name with optional tokens as parameters.

-A -

Ignore predefined assertions and macros.

-B mode

Use with one or more -l options to tell ld what type of library files to search. When mode is dynamic , libraries are shared, meaning that library files ending in both .so and .a are searched. When mode is static , only .a files are searched. To restore the previous search mode for additional -l options, supply -B again and change its mode .

-C

Do not strip comments during preprocessing.

-c

Suppress link editing and keep any object files that were produced.

-D name [ = def ]

Supply a #define directive, defining name to be def or, if no def is given, the value 1 .

-d c

Tell ld to link dynamically when c is y (the default) or to link statically when c is n .

-dalign

Produce double load/store instructions to improve performance. Solaris 2.0 only.

-E

Run only the macro preprocessor, sending results to standard output.

-fast

Use cc options that give fastest compilation. Solaris 2.0 only.

-flags

Briefly describe available options. Solaris 2.0 only.

-fnonstd

Produce SIGFPE signals for floating-point overflows and division by zero. Solaris 2.0 only.

-fsingle

Evaluate float expressions as single-precision. Solaris 2.0 only.

-G

Produce a shared object instead of a dynamically linked executable.

-g

Generate more symbol-table information needed for debuggers dbx (Solaris) or sdb (SVR4).

-H

List (on standard error) the pathnames of header files used in C files .

-I dir

Search for include files in directory dir (in addition to standard locations). Supply a -I for each new dir to be searched.

-K word

If word is PIC , produce position-independent code; if word is minabi , compile with the minimum dynamic linking that preserves ABI conformance.

-keeptmp

Don't delete temporary files. Solaris 2.0 only.

-L dir

Like -I , but search dir for library archives.

-l name

Link source file with library files lib name .so or lib name .a .

-O

Optimize object code (produced by .c or .i files).

-o file

Send object output to file instead of to a.out .

-P

Run only the preprocessor and place the result in file .i .

-p

Generate benchmark code to count the times each routine is called. File mon.out is created, so prof can later be used to produce an execution profile.

-Q c

List in the output ( c = y ) or do not list ( c = n ) information about the compilation tools invoked. Default is to list.

-ql

Invoke the basic block analyzer and produce code to count the times each source line is executed. Use lprof to list the counts.

-qp

Same as -p .

-S

Compile (and optimize, if -O is supplied), but don't assemble or link; assembler output is placed in file .s .

-U name

Remove definition of name, as if through an #undef directive.

-V

Print version information for compiler tools.

-v

Check semantics strictly, and allow some lint constructs to work.

-W[p02abl], arg1 [ , arg2... ]

Each comma-separated argument is a command-line token (option, parameter) from cc . -W hands off these arguments to allow separate processing by a particular compiler tool. p or 0 specifies the compiler; 2 , optimizer; b , basic block analyzer; a , assembler; l , link editor.

-X c

Set c as the level of ANSI C compliance:

t

Transition (default). Source code must comply with pre-ANSI features.

a

ANSI. Code must comply with ANSI features, but doesn't warn about new escape sequences or trigraphs.

c

Conformance. More rigorous than a .

s

Code is allowed to be old Sun C. Solaris 2.0 only.

-xpg

Like -p , but produce file gmon.out ; use gprof to produce an execution profile. Solaris 2.0 only.

-xsb

Produce symbol-table data for Source Code Browser. Solaris 2.0 only.

-xsbfast

Same as -xsb , but don't actually compile. Solaris 2.0 only.

-xstrconst

Add string literals to text segment, not data segment. Solaris 2.0 only.

-Y c , dir

Specify that item c is searched in directory dir . c can be p , 0 , 2 , a , b , or l , as explained under -W . c can also be:

I

Include files to search last for (see -I ).

P

Libraries; dir is a list of directories, separated by a colon (see -L ).

S

Startup object files.

Example

Compile xpop.c and link it to the X libraries:



cc -o xpop xpop.c -lXaw -lXmu -lXt -lX11


Previous: Reference: cb UNIX in a Nutshell: System V Edition Next: Reference: cd
Reference: cb Book Index Reference: cd

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System