ccgeneric C compiler interface |
Command |
|
cc
[
-A
mode]
[
-c
]
[
-D
name[
=
value]]
[
-E
]
[
-g
]
[
-I
directory]
[
-L
directory]
[
-l
library]
[
-o
output]
[
-O
]
[
-P
listfile]
[
-s
]
[
-S
]
[
-T
value]
[
-U
name]
[
-Wphase,arg
]
files...
- Note:
- This reference page describes the generic C compiler interface provided by
cc
.
cc
serves as an interface to the C compiler and linker on
your system and is provided for use with MKS Make. By providing a common
interface to different compilers, and allowing long command lines when executed
directly by
make
,
cc
allows you to write and use the same makefile across
different systems.
You call
cc
with a
standard command line, and it goes
on to call your favorite C compiler and linker with the required command line.
In this way, the makefile always uses the standard command lines, regardless of
the specific compiler or linker you use. You do not have to change your
makefiles if you want to change your compiler or linker, and you can easily port
your makefiles to different environments.
cc
uses a
compilation configuration file to
convert arguments on a standard command line into the arguments for the command
or sequence of commands needed to call your compiler or linker. If you want to
change your compiler or linker, change the appropriate configuration file;
do not change your makefile.
The default configuration file for
cc
is
/etc/compiler.ccg
You may chose a different configuration file by setting the environment variable
CCG to point to the desired file. Interfaces to popular compilers
for your platform are provided. Other interfaces may be added as they become
available; see your
/etc
directory.
When you install MKS Make, the installation program prompts you for the
compiler you use. If it is one of the recognized compilers, the installation
program installs a customized
startup.mk
for Make and copies the
appropriate
cc
configuration file to /etc/compiler.ccg.
If you want
cc
to temporarily use a different compiler,
you can set the environment variable
CCG to the name of the
configuration file for the desired compiler.
If you rename the
cc
executable, it attempts to find its
default configuration in a
.ccg
file with the same base name
as the renamed executable. For example, if you rename
cc
to
c89
,
c89
looks for a default configuration file
named
c89.ccg
in /etc.
In any case, if you have set the
CCG environment variable,
its value takes precedence.
The
startup.mk
file for MKS Make defines the macros
CC
and
LD
to use the compiler and linker that you currently have
installed. In other words, MKS Make does not use
cc
by
default; you have to edit the default rules file to have these assignments:
CC = cc
LD = cc
If you use a compiler that does not have a configuration file, you can customize
a given configuration file to use your compiler. Read the
cc(5)
miscellaneous information
reference page carefully, and modify an existing configuration to use your
compiler. You can define any sort of interface you want; however, the following
guidelines are suggested as the most universal across different programming
platforms.
- -A mode
- specify a compiler mode.
a ANSI-C
c Kernichan & Richie C
p Posix
- -c
- compiles only; does not attempt to link source files.
- -Dname[=value]
- is passed to C compiler to assign the indicated value to the symbol name
when the C preprocessor is run.
- -E
- sends all preprocessor output to standard output.
- -g
- produces debugging information in the compiled object modules.
- -Idirectory
- is passed to the C compiler, indicating that the given directory
is to be searched for
#include
files.
- -Ldirectory
- if linking, looks for libraries in directory. Most linkers also
look for libraries in the directory pointed to by the environment variable
LIB.
- -llibrary
- if linking, adds the indicated library to the list of libraries to be
linked.
- -o output
- if linking, places the executable output in the file output.
- -O
- generate optimized code.
- -P listfile
- produce a listing file.
- -s
- strips debugging information from the output file when linking.
- -S
- produces assembler listing with source code.
- -T value
- specify a stack size.
- -Uname
- is passed to the C compiler, to undefine the symbol name.
- -Wphase,arg
- passes arg to the specified compile phase.
c to the compiler
l to the link indirect file
L to the link editor command line
- file.c
- compiles file.c, and adds file.obj to the list of objects
to be linked.
- file.o
- file.a
- file.sl
- adds the object or library file to the list of files to be linked.
- CCG
- identifies the configuration file for the desired compiler. If
CCG contains
-
, cc
reads the default configuration from the standard input. If
CCG contains a file name, cc
uses that
file as its default configuration file. If CCG contains a
directory name, cc
looks for the default configuration
in the cc.ccg
file in that directory. If the executable has
been renamed, it looks for the default configuration in a
.ccg
file with the same name as the executable. For example,
if cc
is renamed to c89
, it looks for the
default configuration in $CCG/c89.ccg
.
When you use a
cc
command as created with MKS Make's
ccg
, the possible exit status values are:
- 0
- Successful completion.
- 1
- Failure due to one of the following.
- — Cannot open program file
- — Non-string value where string required
- — Divide by 0
- — Unknown math operator
- — Invalid argument to access() function
- — String argument expected for filepath() function
- — Directory separator string has been changed
- — Bad type to length() function
- — Tempfile name is a non-string value
- — Vector assignment to non-vector
- — Vector index out of range
- — '[]' operator applied to non-vector
- — Attempt to use negative vector index
- — Non-string argument to replace() function
- — Non-string argument to substr() function
- — Bad iteration list to FOR statement
- — Bad advance <label>: no nested FOR using <label>
- — Cannot write on file
- — Bad type in sweep
- — String too long
- — Bad operator
- — Unterminated string
- — Bad string escape sequence
- — EOF reading name
- — EOF reading number
- — Unknown character in program file
- — EOF reading operator
- — Advance: not in FOR loop
- — FOR: too deeply nested
- — Program too complex to load
- — No space for request
- 127
- Failure because
cc
cannot run a program, found too
many arguments in an executed string, or was unable to run the specified
string.
If
cc
terminates because of an
exit
directive in the
ccg
input, the exit status is the status specified with the
exit
statement.
On UNIX systems, there is a
cc
command with a similar
command line and set of options; however, precise details may vary from system
to system.
The parser stack depth has a limit of 150 levels.
- Commands:
ar,
ld,
make,
strip
- Miscellaneous:
cc(5)