The Microsoft C Optimizing Compiler consists of three executable files—— C1.EXE, C2.EXE, and C3.EXE——that implement the C preprocessor, language translator, code generator, and code optimizer. An additional control program, CL.EXE, executes the three compiler files in order, passing each the necessary information about filenames and compilation options.
Before using the C compiler and the linker, you need to set up four environment variables:
Variable Action
PATH=path Specifies the location of the three executable C
compiler files (C1, C2, and C3) if they are not
in the current directory; used by CL.EXE.
INCLUDE=path Specifies the location of #include files (default
extension .H) that are not found in the current
directory.
LIB=path Specifies the location(s) for object-code
libraries that are not found in the current
directory.
TMP=path Specifies the location for temporary working
files created by the C compiler and linker.
CL.EXE does not support an interactive mode or response files. You always invoke it with a command line of the following form:
CL [options] file [file ...]
You may list any number of files——if a file has a .C extension, it will be compiled into a relocatable-object-module (.OBJ) file. Ordinarily, if the compiler encounters no errors, it automatically passes all resulting .OBJ files and any additional .OBJ files specified in the command line to the linker, along with the names of the appropriate runtime libraries.
The C compiler has many optional switches controlling its memory models, output files, code generation, and code optimization. These are summarized in Figure 4-2. The C compiler's arcane switch syntax is derived largely from UNIX/XENIX, so don't expect it to make any sense.
Switch Meaning
/Ax Select memory model:
C = compact model
H = huge model
L = large model
M = medium model
S = small model (default)
/c Compile only; do not invoke linker.
/C Do not strip comments.
/D<name>[=text] Define macro.
/E Send preprocessor output to standard output.
/EP Send preprocessor output to standard output
without line numbers.
/F<n> Set stack size (in hexadecimal bytes).
/Fa [filename] Generate assembly listing.
/Fc [filename] Generate mixed source/object listing.
/Fe [filename] Force executable filename.
/Fl [filename] Generate object listing.
/Fm [filename] Generate map file.
/Fo [filename] Force object-module filename.
/FPx Select floating-point control:
a = calls with alternate math library
c = calls with emulator library
c87 = calls with 8087 library
i = in-line with emulator (default)
i87 = in-line with 8087
/Fs [filename] Generate source listing.
/Gx Select code generation:
0 = 8086 instructions (default)
1 = 186 instructions
2 = 286 instructions
c = Pascal style function calls
s = no stack checking
t[n] = data size threshold
/H<n> Specify external name length.
/I<path> Specify additional #include path.
/J Specify default char type as unsigned.
/link [options] Pass switches and library names to linker.
/Ox Select optimization:
a = ignore aliasing
d = disable optimizations
i = enable intrinsic functions
l = enable loop optimizations
n = disable "unsafe" optimizations
p = enable precision optimizations
r = disable in-line return
s = optimize for space
/Ox t = optimize for speed (default)
w = ignore aliasing except across function
calls
x = enable maximum optimization (equivalent to
/Oailt /Gs)
/P Send preprocessor output to file.
/Sx Select source-listing control:
l<columns> = set line width
p<lines> = set page length
s<string> = set subtitle string
t<string> = set title string
/Tc<file> Compile file without .C extension.
/u Remove all predefined macros.
/U<name> Remove specified predefined macro.
/V<string> Set version string.
/W<n> Set warning level (0—3).
/X Ignore "standard places" for include files.
/Zx Select miscellaneous compilation control:
a = disable extensions
c = make Pascal functions case-insensitive
d = include line-number information
e = enable extensions (default)
g = generate declarations
i = include symbolic debugging information
l = remove default library info
p<n> = pack structures on n-byte boundary
s = check syntax only
Figure 4-2. Microsoft C Optimizing Compiler version 5.1 switches.