Name

cc

Synopsis

    cc [options]files

Compile one or more C source files (.c), assembler source files (.s), or preprocessed C source files (.i). cc automatically invokes the loader 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.

General Notes

  • On GNU/Linux and Mac OS X, cc is just a frontend for GCC, the GNU Compiler Collection.

  • Options for cc vary wildly across Unix systems. We have chosen here to document only those options that are commonly available. You will need to check your local documentation for complete information.

  • Usually, cc passes any unrecognized options to the loader, ld.

Solaris Notes

  • Solaris does not come with Sun’s C compiler. If you purchase Sun’s compiler, it will be installed in /opt/SUNWspro/bin. You should add that directory to your PATH. Solaris does make GCC available in /usr/sfw/bin, so if you installed the optional software, you may choose to use GCC instead.

  • The other tools that the C and C++ compilers need (the assembler and loader) are found in /usr/ccs/bin. You should add that directory to your PATH also.

Options

-c

Suppress loading and keep any object files that were produced.

-Dname[=def]

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

-E

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

-g

Generate more symbol-table information needed for debuggers. ...

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.