C/C++ Compiler Options

This chapter describes the options for the Watcom C/C++ compiler, in the following sections:

Compiler options - summarized alphabetically

In this section, we present a terse summary of compiler options. This summary is displayed on the screen by simply entering the compiler command name (wcc, wpp, wcc386, or wpp386) with no arguments.


Note: Most of the time you'll likely use the cc command instead of invoking the Watcom C/C++ compiler directly. See the description of the cc command in the Watcom Utilities Reference for more information.

0
(wcc/wpp only) use only 8088 and 8086 instructions
1
(wcc/wpp only) use 188 and 186 instructions as well
2
(wcc/wpp only) use 286 instructions as well
3
(wcc/wpp only) use 386 instructions, optimizing for Intel 386 instruction timings
4
(wcc/wpp only) use 486 instructions, optimizing for Intel 486 instruction timings
5
(wcc/wpp only) use Pentium instructions, optimizing for Pentium instruction timings
3[r]
(wcc386/wpp386 only) generate 386 instructions based on 386 instruction timings, and use register-based argument-passing conventions
3s
(wcc386/wpp386 only) generate 386 instructions based on 386 instruction timings, and use stack-based argument-passing conventions
4[r]
(wcc386/wpp386 only) generate 386 instructions based on 486 instruction timings, and use register-based argument-passing conventions
4s
(wcc386/wpp386 only) generate 386 instructions based on 486 instruction timings, and use stack-based argument-passing conventions
5[r]
(wcc386/wpp386 only) generate 386 instructions based on Intel Pentium instruction timings, and use register-based argument-passing conventions (default)
5s
(wcc386/wpp386 only) generate 386 instructions based on Intel Pentium instruction timings, and use stack-based argument-passing conventions
7
generate in-line 80x87 instructions (equivalent to the fpi87 option below)
b{d,m,w}
build Dynamic link, Multi-thread, or default Windowing application, respectively
bt[=os]
build target for the os operating system
d1{+}
include line number debugging information (C only: d1+ includes typing information for global symbols and local structures and arrays)
d2
include full symbolic debugging information
d3
include full symbolic debugging information with unreferenced type names
dname[=text]
preprocessor #define name [text]
d+
allow extended -d macro definitions
db
generate browsing information
enumber
set the limit on the number of errors (the default is 20)
ee
call an epilogue hook routine
ei
force enums to be of type int
en
emit the routine name before the prologue
ep[number]
call a prologue hook routine, allocating number stack bytes
et
(Pentium only) generate code for Pentium profiling
ew
(C++ only) generate less verbose messages
ez
(wcc386/wpp386 only) generate a Phar Lap Easy OMF-386 object file
fh[q][=file_name]
use precompiled headers
fi=file_name
force file_name to be included
fo=file_name
set the name of the object or preprocessor output file
fp2
generate in-line 80x87 instructions
fp3
generate in-line 387 instructions
fp5
generate in-line 80x87 instructions optimized for the Pentium processor
fpc
generate calls to a floating-point emulation library
fpd
enable generation of code that checks for the Pentium FDIV bug
fpi
(wcc/wpp only) generate in-line 80x87 instructions with emulation (default)

(wcc386/wpp386 only) generate in-line 387 instructions with emulation (default)

fpi87
(wcc/wpp only) generate in-line 80x87 instructions

(wcc386/wpp386 only) generate in-line 387 instructions

fpr
generate 8087 code compatible with older versions of compiler
fr=file_name
specify the name of the error file
ft
(C++ only) try truncated (8.3) header file specification (default)
fx
(C++ only) don't try truncated (8.3) header file specification
g=codegroup
set the code group name
h{w,d,c}
set the debug output format (WATCOM, Dwarf, Codeview)
i=directory
add directory to the list of include directories
j
change char default from unsigned to signed
m{f,s,m,c,l,h}
specify the memory model (flat, small, medium, compact, large, huge). The default is ms for 16-bit, mf for 32-bit.
nc=name
set the name of the code class
nd=name
set the name of the data segment
nm=name
set the module name to be different from the filename
nt=name
set the name of the text segment
o{a,c,d,e,f,f+,i,l,l+,m,n,o,p,r,s,t,u,x}
control optimization
p{e,l,c,w=num}
preprocess file only, sending output to standard output:
c
include comments
e
encrypt identifiers (C++ only)
l
include #line directives
w=num
wrap output lines at num columns (zero means no wrapping)
r
save/restore segment registers
ri
return chars and shorts as ints
s
remove stack overflow checks
sg
generate calls to grow the stack
st
touch stack through SS first
t=num
set the tab stop multiplier
uname
preprocessor #undef name
v
output function declarations to .def file (with typedef names)
wnumber
set the warning level number (the default is w1)
wcd=number
disable the compiler message with the given number
wce=number
enable the compiler message with the given number
we
treat all warnings as errors
wo
(16-bit only, C only) warn about problems with overlaid code
wx
set the warning level to the maximum setting
xd
(C++ only) disable exception handling (default)
xdt
(C++ only) disable exception handling (same as xd)
xds
(C++ only) disable exception handling (table-driven destructors)
xs
(C++ only) enable exception handling
xst
(C++ only) enable exception handling (direct calls for destruction)
xss
(C++ only) enable exception handling (table-driven destructors)
za
disable language extensions (enabled by default). Enable language extensions with the ze option.
zc
place literal strings in the code segment
zd{f,p}
allow the DS register to float, or peg it to DGROUP (the default is zdp)
zdl
(wcc386/wpp386 only) load DS register directly from DGROUP
ze
enable language extensions (the default setting). Disable language extensions with the za option.
zf{f,p}
allow the FS register to be used (the default for all but the flat memory model) or not used (the default for the flat memory model)
zg
output function declarations to .def (without typedef names)
zg{f,p}
allow the GS register to be used or not used, respectively
zk0
double-byte char support for Kanji
zk0u
translate Kanji double-byte characters to UNICODE
zk1
double-byte char support for Chinese/Taiwanese
zk2
double-byte char support for Korean
zku=codepage
load the UNICODE translation table for the specified code page
zl
suppress the generation of library file names and references in the object file
zld
suppress the generation of file-dependency information in the object file
zm
generate individual functions into separate segments
zo
(C++ only) use exception-handling for a specific operating system
zp[{1,2,4,8}]
set minimal structure packing (member alignment) (default is zp1)
zq
operate quietly
zs
syntax check only
ztnumber
set the data threshold (the default is zt32767)
zu
don't assume that SS contains the segment of DGROUP
zv
make sizeof (void) == 1, so you can directly increment or decrement void pointers without having to do type-casting
zw
Microsoft Windows prologue/epilogue code sequences
zW
(wcc/wpp only) Microsoft Windows optimized prologue/epilogue code sequences
zWs
(wcc/wpp only) Microsoft Windows smart callback sequences
zz
remove @size from __stdcall function names (10.0-compatible)

Compiler options - summarized by category

In the following sections, we present a terse summary of compiler options organized into the following categories:

Target-specific

b{d,m,w}
build Dynamic link, Multi-thread, or default Windowing application, respectively
bt[=os]
build target for operating system os
of
generate traceable stack frames as needed
of+
always generate traceable stack frames
sg
generate calls to grow the stack
st
touch the stack through SS first
zw
generate code for Microsoft Windows
zW
(wcc/wpp only) Microsoft Windows optimized prologue/epilogue code sequences
zWs
(wcc/wpp only) Microsoft Windows smart callback sequences

Debugging / Profiling

d1
line number debugging information
d1+
line number debugging information
d2
full symbolic debugging information
d3
full symbolic debugging with unreferenced type names
ee
call an epilogue hook routine
en
emit routine names in the code segment
ep[number]
call a prologue hook routine, allocating number stack bytes
et
Pentium profiling
h{w,d,c}
set the debug output format (Watcom, Dwarf, Codeview)
s
remove stack-overflow checks

Preprocessor

dname[=text]
precompilation #define name [text]
d+
allow extended d macro definitions on command line
fo=file_name
set the name of the preprocessor output file
p{e,l,c,w=num}
preprocess file
c
preserve comments
e
encrypt identifiers (C++ only)
l
insert #line directives
w=num
wrap output lines at num columns. Zero means no wrapping.
uname
undefine the macro called name

Diagnostics

enumber
set the limit on the number of errors
ew
(C++ only) alternate error message formatting
fr=file_name
set the name of the error file
t=num
set the tab stop multiplier
wnumber
set the warning level number
wcd=number
disable the compiler message with the given number
wce=number
enable the compiler message with the given number
we
treat all warnings as errors
wx
set the warning level to the maximum setting
za
disable language extensions
ze
enable language extensions
zq
operate quietly
zs
check syntax only; don't generate object code

Source / Output control

db
generate browsing information
ez
generate PharLap EZ-OMF object files
fh[q][=file_name]
use precompiled headers
fi=file_name
force file_name to be included
fo=file_name
set the name of the object or preprocessor output file
ft
(C++ only) try truncated (8.3) header file specification (default)
fx
(C++ only) don't try truncated (8.3) header file specification
i=directory
add another include directory
v
output function declarations to .def
zg
generate function prototypes using base types
zl
remove default library information
zld
remove file dependency information

Code Generation

ei
force enumerated types to be type int
j
change the char default from unsigned to signed
ri
return chars and shorts as ints
zc
place literal strings in the code segment
zp{1,2,4,8}
pack structure members
ztnumber
set the data threshold

Floating Point

fpc
calls to floating-point library
fpi
in-line 80x87 instructions with emulation
fpi87
in-line 80x87 instructions
fp2
generate floating-point for 80x87
fp3
generate floating-point for 387
fp5
optimize floating-point for Pentium
fpd
enable the generation of code to check for the Pentium FDIV bug
7
in-line 80x87 instructions

Segments / Modules

g=codegroup
set the code group name
nc=name
set the code class name
nd=name
set the data segment name
nm=name
set the module name
nt=name
set the name of the text segment
zm
place each function in a separate segment

Runtime conventions

3r
386 register calling conventions
3s
386 stack calling conventions
4r
486 register calling conventions
4s
486 stack calling conventions
5r
Pentium register calling conventions
5s
Pentium stack calling conventions
m{f,s,m,c,l,h}
memory model (flat, small, medium, compact, large, huge)
zdf
DS floats (that is, it isn't fixed to DGROUP)
zdp
DS is pegged to DGROUP
zdl
Load DS directly from DGROUP
zff
FS floats (that is, it isn't fixed to a segment)
zfp
FS is pegged to a segment
zgf
GS floats (that is, it isn't fixed to a segment)
zgp
GS is pegged to a segment
zu
SS != DGROUP

Optimizations

oa
relax aliasing constraints
oc
disable the optimization that replaces a call followed by a return by a jump
od
disable all optimizations
oe[=num]
expand user functions in-line. num controls the maximum size
oi
expand intrinsic functions in-line
ol
enable loop optimizations
ol+
enable loop optimizations with loop unrolling
om
generate in-line 80x87 code for math functions
on
allow numerically unstable optimizations
oo
continue compilation even if the computer is low on memory
op
generate consistent floating-point results
or
reorder instructions for the best pipeline usage
os
favor code size over execution time in optimizations
ot
favor execution time over code size in optimizations
ou
all functions must have unique addresses
ox
equivalent to -oilmr -s
oz
NULL points to valid memory in the target environment

C++ exception handling

xd
(C++ only) disable exception handling (default)
xdt
(C++ only) disable exception handling (same as xd)
xds
(C++ only) disable exception handling (table-driven destructors)
xs
(C++ only) enable exception handling
xst
(C++ only) enable exception handling (direct calls for destruction)
xss
(C++ only) enable exception handling (table-driven destructors)
zo
(C++ only) use exception-handling for a specific operating system

Double-byte / Unicode characters

zk{0,1,2}
double-byte char support: 0=Kanji,1=Chinese/Taiwanese,2=Korean
zk0u
translate double-byte Kanji to UNICODE
zku=codepage
load UNICODE translate table for specified code page

Compatibility with older versions

r
save/restore segment registers across calls
fpr
generate backward-compatible 80x87 code
zz
generate backward-compatible __stdcall conventions by removing the @size from __stdcall function names (10.0-compatible)

Compiler options - full description

In the following sections, we present complete descriptions of the compiler options.

0

(wcc/wpp only) The compiler makes use of only 8086 instructions in the generated object code. This is the default. The resulting code runs on 8086 and all upward-compatible processors. The macro __SW_0 is predefined if 0 is selected.

1

(wcc/wpp only) The compiler makes use of 186 instructions in the generated object code whenever possible. The resulting code probably won't run on 8086-compatible processors, but it will run on 186 and upward-compatible processors. The macro __SW_1 is predefined if 1 is selected.

2

(wcc/wpp only) The compiler makes use of 286 instructions in the generated object code whenever possible. The resulting code probably won't run on 8086- or 186-compatible processors, but it will run on 286 and upward-compatible processors. The macro __SW_2 is predefined if 2 is selected.

3

(wcc/wpp only) The compiler makes use of some 386 instructions and FS or GS (if the zff or zgf option is used) in the generated object code whenever possible. The code is optimized for 386 processors. The resulting code probably won't run on 8086-, 186- or 286-compatible processors, but it will run on 386 and upward-compatible processors. The macro __SW_3 is predefined if 3 is selected.

3r, 3s

(wcc386/wpp386 only) The compiler generates 386 instructions based on 386 instruction timings (see 4 and 5 below).

If the r (or no) suffix is specified, the following machine-level code strategy is employed:

  • The compiler passes arguments in registers whenever possible. This is the default method used to pass arguments (unless the bt=netware option is specified).
  • All registers except EAX are preserved across function calls.
  • When any form of the fpi option is used, the result of functions of type float and double is returned in ST(0).
  • When the fpc option is used, the result of a function of type float is returned in EAX, and the result of a function of type double is returned in EDX:EAX.
  • The resulting code is smaller than that which is generated for the stack-based method of passing arguments (see 3s below).
  • The default naming convention for all global functions is such that an underscore character (_) is suffixed to the symbol name.
  • The default naming convention for all global variables is such that an underscore character (_) is prefixed to the symbol name.

If the s suffix is specified, the following machine-level code strategy is employed:

  • The compiler passes all arguments on the stack.
  • The EAX, ECX and EDX registers aren't preserved across function calls.
  • The FS and GS registers aren't preserved across function calls.
  • The result of a function of type float is returned in EAX. The result of a function of type double is returned in EDX:EAX.
  • The resulting code is larger than that generated for the register method of passing arguments (see 3r above).
  • The naming convention for all global functions and variables is modified such that no underscore characters (_) are prefixed or suffixed to the symbol name.

The s conventions are similar to those used by the MetaWare High C 386 compiler.

By default, r is selected if neither r nor s is specified.

The macro __SW_3 is predefined if 3 is selected. The macro __SW_3R is predefined if r is selected (explicitly or by default). The macro __SW_3S is predefined if s is selected.

4

(wcc/wpp only) The compiler makes use of some 386 instructions and FS or GS (if the zff or zgf options is used) in the generated object code whenever possible. The code is optimized for 486 processors. The resulting code probably won't run on 8086-, 186- or 286-compatible processors, but it will run on 386 and upward-compatible processors. The macro __SW_4 is predefined if 4 is selected.

4r, 4s

(wcc386/wpp386 only) This option is identical to 3{r|s}, except that the compiler generates 386 instructions based on 486 instruction timings. The code is optimized for 486 processors rather than 386 processors. By default, r is selected if neither r nor s is specified. The macro __SW_4 is predefined if 4 is selected. The macro __SW_3R is predefined if r is selected (explicitly or by default). The macro __SW_3S is predefined if s is selected.

5

(wcc/wpp only) The compiler makes use of some 386 instructions and FS or GS (if the zff or zgf option is used) in the generated object code whenever possible. The code is optimized for the Intel Pentium processor. The resulting code probably won't run on 8086-, 186- or 286-compatible processors, but it will run on 386 and upward-compatible processors. The macro __SW_5 is predefined if 5 is selected.

5r, 5s

(wcc386/wpp386 only) This option is identical to 3{r|s}, except that the compiler generates 386 instructions based on Intel Pentium instruction timings. The code is optimized for Intel Pentium processors rather than 386 processors. By default, r is selected if neither r nor s is specified.

The macro __SW_5 is predefined if 5 is selected. The macro __SW_3R is predefined if r is selected (explicitly or by default). The macro __SW_3S is predefined if s is selected.

7

(wcc/wpp only) The compiler generates in-line 80x87 numeric data processor instructions into the object code for floating-point operations.

(wcc386/wpp386 only) The compiler generates in-line 387-compatible numeric data processor instructions into the object code for floating-point operations.

This option is equivalent to fpi87. The macros __FPI__ and __SW_FPI87 is predefined if 7 is selected.

b{d,m,w}

These options determine the type of application to build:


Note: The b{d,m,w} options don't apply to QNX.

bd
(OS/2, Windows NT only) This option causes the compiler to imbed the appropriate DLL library name in the object file and to include the appropriate DLL initialization code sequence when the application is linked. The macro __SW_BD is predefined if bd is selected.
bm
(Netware, OS/2, Windows NT only) This option causes the compiler to imbed the appropriate multi-thread library name in the object file. The macro __SW_BM is predefined if bm is selected.
bw
(OS/2, Windows 3.x, Windows NT only) This option causes the compiler to import a special symbol so that the default windowing library code is linked into your application. The macro __SW_BW is predefined if bw is selected.

bt=[os]

This option causes the compiler to define the build target. This option is used for cross-development work. It prevents the compiler from defining the default build target (which is based on the host system the compiler is running on). The default build targets are:

  • DOS
  • OS2
  • NT
  • QNX

The bt options also prevents the compiler from defining the default system macro. Instead the compiler defines a macro consisting of the string os, converted to uppercase and prefixed and suffixed with two underscores. The default system macros are described in ``Predefined Macros'' in the chapter C/C++ Compilers.

For example, specifying the option bt=foo causes the compiler to define the macro __FOO__, and prevent it from defining:

  • MSDOS and __DOS__, if the compiler is being run under DOS
  • __OS2__, if using the OS/2-hosted compiler
  • __NT__, if using the Windows NT-hosted compiler
  • or __QNX__, if using the QNX-hosted version.

Any string consisting of letters, digits, and the underscore character may be used for the system name.

The compiler also constructs an environment variable called os_INCLUDE, and see if it has been defined. If the environment variable is defined, then each directory listed in it is searched (in the order that they're specified). For example, the environment variable WINDOWS_INCLUDE is searched if bt=WINDOWS option is specified.

    export WINDOWS_INCLUDE=/watcom.h/win

The processing of include files is described in the section ``#include File Processing'' in the chapter on C/C++ Compilers.

Several system names are recognized by the compiler and perform additional operations:

DOS
Defines the macro MSDOS.
WINDOWS
Same as specifying the zw option. The 32-bit compiler additionally defines the macro __WINDOWS_386__.
NETWARE
(wcc386/wpp386 only) Causes the compiler to use stack-based calling conventions unless overridden by the 3r, 4r or 5r options. Also defines the macro __NETWARE_386__.

Specifying bt with no system name following restores the default system name.

dname[=text]

The specified definition is included as if it were part of the source code. Using this option is equivalent to including the following line in your source code:

#define name [text]

For example, the option

    d_MODDATE="87/05/04"

is equivalent to the following line in the source file:

    #define _MODDATE "87/05/04"

d+

The syntax of any d option that follows on the command line is extended to include C/C++ tokens as part of text. The token string is terminated by a space character. This permits more complex syntax than is normally allowed.

For example,

    -d+ -d_radx=x*3.1415926/180

is equivalent to specifying the following in the source code:

    #define _radx x*3.1415926/180

Watcom C++ extends this feature by allowing parameterized macros. When a parameter list is specified, the ``='' character must not be specified. It also permits immediate definition of the macro as shown in the second line of the example:

    -d+ -d_rad(x)x*3.1415926/180
    -d+_rad(x)x*3.1415926/180

Either of these is equivalent to specifying the following in the source code:

    #define _rad(x) x*3.1415926/180

Debugging options

The following debugging options are available:

d1

Line number debugging information is included in the object file. This option provides additional information to the Watcom Debugger (at the expense of larger object files and executable files). Line numbers are handy when debugging your application with the Watcom Debugger at the source code level. Code speed isn't affected by this option.

To avoid recompiling, the Watcom Strip utility can be used to remove debugging information from the executable image.

d1+

(C only) Line number debugging information plus typing information for global symbols and local structs and arrays is included in the object file. Although global symbol information can be made available to the Watcom Debugger through a Watcom Linker option, typing information for global symbols and local structs and arrays must be requested when the source file is compiled. This option provides additional information to the Watcom Debugger (at the expense of larger object files and executable files). Code speed is affected (but not by much) by this option.

To avoid recompiling, the Watcom Strip utility can be used to remove debugging information from the executable image.

d2

In addition to line number information, local symbol and data type information is included in the object file. Although global symbol information can be made available to the Watcom Debugger through a Watcom Linker option, local symbol and typing information must be requested when the source file is compiled. This option provides additional information to the Watcom Debugger (at the expense of larger object files and executable files).

By default, the compiler selects the od level of optimization if d2 is specified. Code speed is affected adversely by this option, but it makes the debugging chore somewhat easier. To create production code, you must recompile without this option.

d3

This option is identical to d2 but also includes symbolic debugging information for unreferenced type names.


Note: This can result in very large object and/or executable files when header files such as WINDOWS.H or OS2.H are included.

db

Use this option to generate browsing information. The browsing information is recorded in a file whose name is constructed from the source file name and the extension .mbr.

enumber

The compiler stops compilation after reaching number errors. By default, the compiler stops compilation after 20 errors.

ee

This option causes the compiler to generate a call to __EPI in the epilogue sequence at the end of every function. This user-written routine can be used to collect/record profiling information. Other related options are ep and en. The macro __SW_EE is predefined if ee is selected.


Note: This option doesn't apply to QNX.

ei

By default, the compiler allocates the smallest storage unit required to hold all possible values given for an enumerated list. This option can be used to force the compiler to allocate an int for all enumerated types. The macro __SW_EI is predefined if ei is selected.

en

This option causes the compiler to emit the function name into the object code as a string of characters just before the function prologue sequence is generated. The string is terminated by a byte count of the number of characters in the string.

    ; void Toaster( int arg )

        db        "Toaster", 7
    public  Toaster
    Toaster label   byte
        .
        .
        .
        ret

This option is intended for developers of embedded systems (ROM-based applications). It may also be used in conjunction with the ep option for special user-written profiling applications. The macro __SW_EN is predefined if en is selected.

ep [number]

This option causes the compiler to generate a call to a user-written __PRO routine in the prologue sequence at the start of every function. This routine can be used to collect/record profiling information. The optional argument number can be used to cause the compiler to allocate that many bytes on the stack as a place for __PRO to store information.

Other related options are ee and en. The macro __SW_EP is predefined if ep is selected.


Note: This option doesn't apply to QNX.

et

(Pentium only) This option causes the compiler to generate code into the prolog of each function to count exactly how much time is spent within that function, in clock ticks. This option is valid only for Pentium-compatible processors (that is, the instructions inserted into the code don't work on 486 or earlier architectures).

At the end of the execution of the program, a file with the same name as the program and an extension of .prf is written. The contents of the file will look like this:

      1903894223          1  main
      1785232334    1376153  StageA
      1882249150      13293  StageB
      1830895850       2380  StageC
       225730118         99  StageD

The columns are as follows:

  • The first column is the total number of clock ticks spent inside of the function during the execution of the program, including time spent within functions called from this function.
  • the second column is the number of times the function was called
  • the third column is the function name

The overhead of the profiling can be somewhat intrusive, especially for small leaf functions (that is, it may skew your results somewhat).

ew

(C++ only) This option causes the C++ compiler to generate equivalent but less verbose diagnostic messages.

ez

(wcc386/wpp386 only) The compiler generates an object file in Phar Lap Easy OMF-386 (object module format) instead of the default Microsoft OMF. The macro __SW_EZ is predefined if ez is selected.


Note: This option doesn't apply to QNX.

fh[q][=file_name]

The compiler generates/uses a precompiled header for the first header file referenced by #include in the source file. The fhq option is the same, but prevents the compiler from issuing informational or warning messages about precompiled header files. See the Precompiled Headers chapter for more information.

fi=file_name

The specified file is included as if a

    #include "file_name"

directive were placed at the start of the source file. For example:

    wcc report -fi=/usr/include/stdarg.h
    wpp report -fi=/usr/include/stdarg.h
    wcc386 report -fi=/usr/include/stdarg.h
    wpp386 report -fi=/usr/include/stdarg.h

fo=file_name

The meaning of the fo option depends on what other options you use. If you also use the p preprocessor options, the fo option is used to name the output of the preprocessor. If you aren't using a preprocessor option, the fo option is used to name the object file. These different uses are described in the following sections:

Usage with preprocessor options

The fo option is used with any form of the p (preprocessor) option to name the output file node, path, file name, and extension. If the output file name isn't specified, it's constructed from the source file name. If the output file extension isn't specified, it's .i by default.

For example:

wcc report -p -fo=//2/proj/prep/
wpp report -p -fo=//2/proj/prep/
wcc386 report -p -fo=//2/proj/prep/
wpp386 report -p -fo=//2/proj/prep/

A trailing slash (/) must be specified for directory names. If, for example, the option is specified as fo=//2/proj/prep, then the output file would be called //2/proj/prep.i.

A default filename extension must be preceded by a period (.), as shown in the example below:

wcc report -p -fo=//2/proj/prep/.cpr
wpp report -p -fo=//2/proj/prep/.cpr
wcc386 report -p -fo=//2/proj/prep/.cpr
wpp386 report -p -fo=//2/proj/prep/.cpr

Usage with object files

When generating an object file, the fo option may be used to name the object file node, path, file name, and extension. If the object file name isn't specified, it's constructed from the source file name. If the object file extension isn't specified, it's .o by default.

For example:

wcc report -fo=//2/proj/obj/
wpp report -fo=//2/proj/obj/
wcc386 report -fo=//2/proj/obj/
wpp386 report -fo=//2/proj/obj/

A trailing slash /) must be specified for directory names. If, for example, the option is specified as fo=//2/proj/obj, then the object file is called //2/proj/obj.o.

A default filename extension must be preceded by a period (.), as shown in the example below:

wcc report -fo=//2/proj/obj/.dbo
wpp report -fo=//2/proj/obj/.dbo
wcc386 report -fo=//2/proj/obj/.dbo
wpp386 report -fo=//2/proj/obj/.dbo

fp2

The compiler generates in-line 80x87 numeric data processor instructions into the object code for floating-point operations. For Watcom compilers generating 16-bit code, this option is the default.

For 32-bit applications, use this option if you wish to support those few 386 systems equipped with a 287 numeric data processor (fp3 is the default for Watcom compilers generating 32-bit code). However, for 32-bit applications, the use of this option reduces execution performance. Use this option in conjunction with the fpi or fpi87 options.

The macro __SW_FP2 is predefined if fp2 is selected.

fp3

The compiler generates in-line 387-compatible numeric data processor instructions in the object code for floating-point operations. For 16-bit applications, the use of this option limits the range of systems on which the application will run, but there are execution performance improvements. For Watcom compilers generating 32-bit code, this option is the default. Use this option in conjunction with the fpi or fpi87 options.

The macro __SW_FP3 is predefined if fp3 is selected.

fp5

The compiler generates in-line 80x87 numeric data processor instructions in the object code for floating-point operations. The sequence of floating-point instructions is optimized for greatest possible performance on the Intel Pentium processor.

For 16-bit applications, the use of this option limits the range of systems on which the application will run, but there are execution performance improvements. Use this option in conjunction with the fpi or fpi87 options.

The macro __SW_FP5 is predefined if fp5 is selected.

fpc

All floating-point arithmetic is done with calls to a floating-point emulation library. This option should be used when:

  • speed of floating-point emulation is favoured over code size
  • an application containing floating-point operations is to be stored in ROM, and an 80x87 won't be present in the system

The macro __SW_FPC is predefined if fpc is selected.


Note:

When any module in an application is compiled with the fpc option, then all modules must be compiled with the fpc option.

Different math libraries are provided for applications that have been compiled with a particular floating-point option. See ``C/C++ Math Libraries'' in the C/C++ Libraries chapter.


fpd

A subtle problem has been detected in the FDIV instruction of Intel's original Pentium CPU. In certain rare cases, the result of a floating-point divide has less precision than it should. Contact Intel directly for more information on the issue.

As a result, the runtime system startup code has been modified to test for a faulty Pentium. If the FDIV instruction is found to be flawed, the low order bit of the runtime system variable __chipbug is set.

    extern unsigned __near __chipbug;

If the FDIV instruction doesn't show the problem, the low order bit is clear. If the Pentium FDIV flaw is a concern for your application, there are two approaches you could take:

  1. You can test the __chipbug variable in your code in all floating-point and memory models and take appropriate action (such as displaying a warning message or discontinuing the application).
  2. Alternately, you can use the fpd option when compiling your code. This option directs the compiler, whenever an FDIV instruction is generated, to generate additional code that tests the low order bit of __chipbug and, if on, calls the software workaround code in the math libraries. If the bit is off, an in-line FDIV instruction is performed as before.

If you know that your application will never run on a defective Pentium CPU, or your analysis shows that the FDIV problem won't affect your results, you don't need to use the fpd option.

The macro __SW_FPD is predefined if fpd is selected.

fpi

(wcc/wpp only) The compiler generates in-line 80x87 numeric data processor instructions into the object code for floating-point operations. Depending on which library the code is linked against, these instructions are left as is or they're replaced by special interrupt instructions. In the latter case, floating-point is emulated if an 80x87 isn't present. This is the default floating-point option if none is specified.

(wcc386/wpp386 only) The compiler generates in-line 387-compatible numeric data processor instructions into the object code for floating-point operations. When any module containing floating-point operations is compiled with the fpi option, coprocessor emulation software is included in the application when it's linked.

For 32-bit Watcom Windows-extender applications or 32-bit application run in Windows 3.1 DOS boxes, you must also include the WEMU387.386 file in the [386enh] section of the SYSTEM.INI file.

For example:

device=C:\/usr\binw\wemu387.386

Note that the WDEBUG.386 file that's installed by the Watcom Installation software contains the emulation support found in the WEMU387.386 file.

Thus, a math coprocessor doesn't need to be present at run time. This is the default floating-point option if none is specified. The macros __FPI__ and __SW_FPI are predefined if fpi is selected.


Note:

When any module in an application is compiled with a particular floating-point option, then all modules must be compiled with the same option.

If you wish to have floating-point emulation software included in the application, you should select the fpi option. A math coprocessor doesn't need to be present at run time.

Different math libraries are provided for applications that have been compiled with a particular floating-point option. See ``C/C++ Math Libraries'' in the C/C++ Libraries chapter.


fpi87

(wcc/wpp only) The compiler generates in-line 80x87 numeric data processor instructions into the object code for floating-point operations. An 8087 or compatible math coprocessor must be present at run time. If the 2 option is used in conjunction with this option, the compiler generates 287 and upwards-compatible instructions; otherwise, the compiler generates 8087-compatible instructions.

(wcc386/wpp386 only) The compiler generates in-line 387-compatible numeric data processor instructions into the object code for floating-point operations. When the fpi87 option is used exclusively, coprocessor emulation software isn't included in the application when it is linked. A 387 or compatible math coprocessor must be present at run time.

The macros __FPI__ and __SW_FPI87 are predefined if fpi87 is selected. See the note with the description of the fpi option.

fpr

Use this option if you want to generate floating-point instructions that are compatible with version 9.0 or earlier of the compilers. The macro __SW_FPR is predefined if fpr is selected.

For more information on floating-point conventions see ``Using the 80x87 to Pass Arguments'' in the appropriate chapter:

fr=file_name

The fr option is used to name the error file node, path, file name and extension. If the error file name isn't specified, it's constructed from the source file name. If the output file extension isn't specified, it's .err by default.

For example,

wcc report -fr=//2/proj/errs/
wpp report -fr=//2/proj/errs/
wcc386 report -fr=//2/proj/errs/
wpp386 report -fr=//2/proj/errs/

A trailing / must be specified for directory names. If, for example, the option is specified as fr=//2/proj/errs then the output file is called //2/proj/errs..err.

A default filename extension must be preceded by a period (.), as shown in the example below:

wcc report -fr=//2/proj/errs/.erf
wpp report -fr=//2/proj/errs/.erf
wcc386 report -fr=//2/proj/errs/.erf
wpp386 report -fr=//2/proj/errs/.erf

ft

(C++ only) If the compiler can't open a header file whose file name is longer than 8 letters or whose file extension is longer than 3 letters, it truncates the name at 8 letters and the extension at 3 letters and tries to open a file with the shortened name. This is the default behaviour for the compiler.

For example, if the compiler can't open the header file called strstream.h, it attempts to open a header file called strstrea.h.

fx

(C++ only) This option can be used to disable the truncated header filename processing that the compiler does by default (see ft above).

g=codegroup

The generated code is placed in the group called codegroup. The default text segment name is codegroup_TEXT, but this can be overridden by the nt option.

For example,

wcc report -g=RPTGROUP -s
wpp report -g=RPTGROUP -s
wcc386 report -g=RPTGROUP -s
wpp386 report -g=RPTGROUP -s

Note: (wcc/wpp only)

This is useful when compiling applications for small code models where the total application contains more than 64 kilobytes of code. Each group can contain up to 64 kilobytes of code. The application follows a mixed code model, since it contains a mix of small and large code (intra-segment and inter-segment calls). Memory models are described in 16-bit Memory Models, in the 16-bit Topics supplement to this manual. The far keyword is used to describe routines that are referenced from one group/segment but are defined in another group/segment.

For small code models, the s option should be used in conjunction with the g option to prevent the generation of calls to the C runtime routine that checks for stack overflow (__STK). You must also avoid calls to other small code C runtime library routines since inter-segment near calls to C library routines aren't possible.


h{w,d,c}

The type of debugging information that's to be included in the object file is one of Watcom, Dwarf or Codeview. The default is Watcom.

If you wish to use the Microsoft Codeview debugger, then choose the hc option (this option causes Codeview Level 4 information to be generated). It's necessary to run the Microsoft Debugging Information Compactor, CVPACK, on the executable once the linker has created it. For information on requesting the linker to automatically run CVPACK, see ``CVPACK Option'' in the Watcom Linker chapter. Alternatively, you can run CVPACK from the command line.

When linking the application, you must also choose the appropriate Watcom Linker DEBUG directive.

i=directory

This option adds the specified paths to the list of directories in which the compiler searches for include files. The paths in the directory parameter are separated by colons (for example, path1:path2).

See ``#include file processing''in the C/C++ Compilers chapter for information on searching directories.

j

The default char type is changed from an unsigned to a signed quantity. The macros __CHAR_SIGNED__ and __SW_J are predefined if j is selected.

Memory model options

The m{f,s,m,c,l,h} option is used to specify the memory model to use:

mf
flat model
ms
small model
mm
medium model
mc
compact model
ml
large model
mh
huge model

Note: Memory models are described in the chapter 32-bit Memory Models in this manual, and in the chapter 16-bit Memory Models, in the 16-bit Topics supplement.

Other architectural aspects of the Intel 86 family, such as pointer size, are discussed in ``Sizes of Predefined Types'' in the chapters:


mc

The compact memory model (small code, big data) is selected. The M_I86CM and __COMPACT__ macros are predefined.

mf

(wcc386/wpp386 only) The flat memory model (code and data up to 4 gigabytes) is selected. The __FLAT__ macro is predefined.

mh

(wcc/wpp only) The huge memory model (big code, huge data) is selected. The M_I86HM and __HUGE__ macros are predefined.

ml

The large memory model (big code, big data) is selected. The M_I86LM and __LARGE__ macros are predefined.

mm

The medium memory model (big code, small data) is selected. The M_I86MM and __MEDIUM__ macros are predefined:

ms

The small memory model (small code, small data) is selected. By default, both 16-bit and 32-bit compilers select this memory model. The M_I86SM and __SMALL__ macros are predefined.

nc=name

The default code class name is CODE. The small code model _TEXT segment and the large code model module_name_TEXT segments belong to the CODE class. This option allows you to select a different class name for these code segments. The name of the code class is explicitly set to name.


Note:

The default data class names are DATA (for the CONST, CONST2 and _DATA segments) and BSS (for the _BSS segment). There is no provision for changing the data class names.


nd=name

This option permits you to define a special prefix for the CONST, CONST2, _DATA, and _BSS segment names. The name of the group to which these segments belong is also changed from DGROUP to name_GROUP.

For example,

wcc report -nd=spec
wpp report -nd=spec
wcc386 report -nd=spec
wpp386 report -nd=spec

In the above example, the segment names become specCONST, specCONST2, spec_DATA, and spec_BSS, and the group name becomes spec_GROUP.

By default, the data group DGROUP consists of the CONST, CONST2, _DATA, and _BSS segments. The compiler places certain types of data in each segment. The CONST segment contains constant literals that appear in your source code.

For example,

char *birds[ 3 ] = { "robin", "finch", "wren" };

printf( "Hello world\n" );

In the above example, the strings ``Hello world\n'', ``robin'', ``finch'' and ``wren'' appear in the CONST segment.

The CONST2 segment contains initialized read-only and read/write data such as scalars, structures, and arrays.

For example,

const int cvar = 1;
int var = 2;
int table[ 5 ] = { 1, 2, 3, 4, 5 };
char *birds[ 3 ] = { "robin", "finch", "wren" };

In the above example, the array birds is in the CONST2 segment. The pointers in this array point to the strings ``robin'', ``finch'', and ``wren'', which appear in the CONST segment.

The _BSS segment contains uninitialized data such as scalars, structures, and arrays.

For example,

int var1;
int array1[ 400 ];

Other data segments containing data, specifically declared to be far, or exceeding the data threshold (see the zt option), are named module_nameN_DATA, where N is a number greater than 5.

For example,

int far array2[400];

In the above example, array2 is placed in the segment report6_DATA, provided that the module name is report.

nm=name

By default, the object file name and the module name that's placed in it are built from the source file name. When the nm option is used, the module name that's placed in the object file is name. For large code models, the text segment name is name_TEXT, unless the nt option is used.

In the following example, the preprocessed output from report.c is stored on another node under the name //2/temp.c. The file is compiled with the nm option so that the module name imbedded into the object file is REPORT rather than TEMP:

wcc report -pl -fo=//2/temp.c
wcc //2/temp -nm=report -fo=report

wpp report -pl -fo=//2/temp.c
wpp //2/temp -nm=report -fo=report

wcc386 report -pl -fo=//2/temp.c
wcc386 //2/temp -nm=report -fo=report

wpp386 report -pl -fo=//2/temp.c
wpp386 //2/temp -nm=report -fo=report

Since the fo option is also used, the resulting object file is called report.o.

nt=name

The name of the text segment is explicitly set to name. By default, the text segment name is _TEXT for small code models, and module_name_TEXT for large code models, as shown in the table below:

Application TypeMemory ModelCode Segment
32-bitflat_TEXT
16/32-bitsmall_TEXT
16/32-bitmediummodule_name_TEXT
16/32-bitcompact_TEXT
16/32-bitlargemodule_name_TEXT
16-bithugemodule_name_TEXT

Optimizations

When specified on the command line, optimization options may be specified individually (for example, oa or, oi), or the letters may be strung together (for example, oailt).

The following options are defined:

oa
oc
od
oe=num
of
of+
oi
ol
ol+
om
on
oo
op
or
os
ot
ou
ox
oz

When ox is combined with the on, oe, oa and ot options (oneatx) and the zp4 option, the code generator attempts to give you the fastest executing code possible irrespective of architecture. Other options can give you architecture specific optimizations to further improve the speed of your code. Note that specifying oneatx is equivalent to specifying oneatilmr and s. See ``Benchmarking Hints'' in the C/C++ Compilers chapter for more information on generating fast code.

oa

Alias checking is relaxed. When this option is specified, the code optimizer assumes that global variables aren't indirectly referenced through pointers. This assumption may reduce the size of the code that's generated. The following example helps to illustrate this point:

extern int i;

void rtn( int *pi )
{
    int k;
    for( k = 0; k < 10; ++k ) {
      (*pi)++;
      i++;
    }
}

In the above example, if i and *pi reference the same integer object then i is incremented by 2 each time through the for loop, and we would call the pointer reference *pi an alias for the variable i. In this situation, the compiler can't bind the variable i to a register without making sure that the in-memory copy of i is kept up-to-date.

In most cases, the above situation doesn't arise. Rarely would we reference the same variable directly by name and indirectly through a pointer in the same routine. The oa option instructs the code generator that such cases don't arise in the module to be compiled. The code generator is able to produce more efficient code when it doesn't have to worry about the alias problem.

The macro __SW_OA is predefined if oa is selected.

oc

This option may be used to disable the optimization where a CALL followed by a RET (return) is changed into a JMP (jump) instruction.

(wcc/wpp only) This option is required if you wish to link an overlaid program using the Microsoft DOS Overlay Linker. The Microsoft DOS Overlay Linker creates overlay calls for a CALL instruction only. This option isn't required when using the Watcom Linker.

The macro __SW_OC is predefined if oc is selected.

od

Non-optimized code sequences are generated. The resulting code is much easier to debug when using the Watcom Debugger. By default, the compiler selects od if d2 is specified. If d2 is followed by one of the other o options then od is overridden, such as in the following example:

wcc report -d2 -os
wpp report -d2 -os
wcc386 report -d2 -os
wpp386 report -d2 -os

The macro __SW_OD is predefined if od is selected.

oe=num

Certain user functions are expanded in-line. The criteria for which functions are selected for in-line expansion is based on the size of the function in terms of the number of quads generated by the function. A quad (quadruple) consists of four components: an operator, two arguments and a result (hence the name). All expressions can be decomposed into a series of quads. For example, the statement a = -b * (c + d) can be broken down into the following quads:

OperatorArgument 1Argument 2Result
uminusb t1
+cdt2
*t1t2t3
=t3 a

The number of quads generated corresponds closely to the number of operators used in an expression. Functions that require more than num quads aren't expanded in-line. The default number is 20. This optimization is useful when locally-referenced functions are small in size.

For example,

wcc dhrystone -oe
wpp dhrystone -oe
wcc386 dhrystone -oe
wpp386 dhrystone -oe

of

This option selects the generation of traceable stack frames for those functions that contain calls or require stack frame setup.

(wcc/wpp only) To use Watcom's Dynamic Overlay Manager (DOS only), you must compile all modules using one of the of or of+ options (of is sufficient).

For near functions, the following function prologue sequence is generated:

(wcc/wpp only)
    push BP
    mov  BP,SP

(wcc386/wpp386 only)
    push EBP
    mov  EBP,ESP

For far functions, the following function prologue sequence is generated:

(wcc/wpp only)
    inc  BP
    push BP
    mov  BP,SP

(wcc386/wpp386 only)
    inc  EBP
    push EBP
    mov  EBP,ESP

The BP or EBP value on the stack is even or odd, depending on the code model.

For 16-bit DOS systems, the Dynamic Overlay Manager uses this information to determine if the return address on the stack is a short address (16-bit offset) or long address (32-bit segment:offset).

    wcc toaster -of

The macro __SW_OF is predefined if of is selected.

of+

This option selects the generation of traceable stack frames for all functions, regardless of whether they contain calls or require stack frame setup. This option is intended for developers of embedded systems (ROM-based applications).

To use Watcom's Dynamic Overlay Manager (16-bit DOS only), you must compile all modules using one of the of or of+ options (of is sufficient).

For near functions, the following function prologue sequence is generated:

(wcc/wpp only)
    push BP
    mov  BP,SP

(wcc386/wpp386 only)
    push EBP
    mov  EBP,ESP

For far functions, the following function prologue sequence is generated:

(wcc/wpp only)
    inc  BP
    push BP
    mov  BP,SP

(wcc386/wpp386 only)
    inc  EBP
    push EBP
    mov  EBP,ESP

The BP or EBP value on the stack is even or odd, depending on the code model.

For 16-bit DOS systems, the Dynamic Overlay Manager uses this information to determine if the return address on the stack is a short address (16-bit offset) or long address (32-bit segment:offset).

    wcc toaster -of+

oi

Certain library functions are generated in-line. You must include the appropriate header file containing the prototype for the desired function so that it's generated in-line. The functions that can be generated in-line only for wcc/wpp are:

memset()
strcmp()

The functions that can be generated in-line only for wcc386/wpp386 are:

inpd()
ldiv()
_lrotl()
_lrotr()
outpd()

The functions that can be generated in-line for all the compilers are:

abs()
_disable()
div()
_enable()
fabs()
_fmemchr()
_fmemcmp()
_fmemcpy()
_fmemset()
_fstrcat()
_fstrcmp()
_fstrcpy()
_fstrlen()
inp()
inpw()
labs()
memchr()
memcmp()
memcpy()
movedata()
outp()
outpw()
_rotl()
_rotr()
strcat()
strchr()
strcpy()
strlen()

The macros __INLINE_FUNCTIONS__ and __SW_OI are predefined if oi is selected.

ol

Loop optimizations are performed. This includes moving loop-invariant expressions outside the loops. The macro __SW_OL is predefined if ol is selected.

ol+

Loop optimizations are performed, including loop unrolling. This includes moving loop-invariant expressions outside the loops, and turning some loops into straight-line code. The macro __SW_OL is predefined if ol+ is selected.

om

Generate in-line 80x87 code for math functions such as sin(), cos() and tan(). If this option is selected, it's your responsibility to make sure that arguments to these functions are within the range accepted by the corresponding in-line instructions (fsin(), fcos(), and so on), since no runtime check is made. For 16-bit machines, you must also include the fp3 option to get in-line 80x87 code (except for fabs()). The functions that can be generated in-line are:

atan()
cos()
exp()
fabs()
log10()
log()
sin()
sqrt()
tan()

If the ot option is also specified, the exp() function is generated in-line as well.

The macro __SW_OM is predefined if om is selected.

on

This option allows the compiler to replace floating-point divisions with multiplications by the reciprocal. This generates faster code, but the result may not be the same because the reciprocal may not be exactly representable. The macro __SW_ON is predefined if on is selected.

oo

By default, the compiler aborts compilation if it runs low on memory. This option forces the compiler to continue anyway.


Note: This can result in the generation of very poor code.

The macro __SW_OO is predefined if oo is selected.

op

This option causes to compiler to store intermediate floating-point results in memory, in order to generate consistent floating-point results, rather than keeping values in the 80x87 registers, where they have more precision. The macro __SW_OP is predefined if op is selected.

or

This option enables the reordering of instructions (instruction scheduling) to achieve better performance on pipelined architectures such as the Intel 486 and Pentium processors. This option is essential for generating fast code for the Intel Pentium processor.


Note: Selecting this option makes it slightly more difficult to debug because the assembly language instructions generated for a source statement may be intermixed with instructions generated for surrounding statements.

The macro __SW_OR is predefined if or is selected.

os

Space is favoured over time when generating code (smaller code but possibly slower execution). By default, the compiler selects a balance between space and time. The macro __SW_OS is predefined if os is selected.

ot

Time is favoured over space when generating code (faster execution but possibly larger code). By default, the compiler selects a balance between space and time. The macro __SW_OT is predefined if ot is selected.

ou

This option forces the compiler to make sure that all function labels are unique. Thus the compiler won't place two function labels at the same address even if the code for the two functions is identical. This option is automatically selected if the za option is specified. The macro __SW_OU is predefined if ou is selected.

ox

The oilmr and s (no stack overflow checking) options are selected.

oz

This option prevents the compiler from omitting NULL pointer checks on pointer conversions. By default, the compiler omits these checks when it's safe to do so. Consider the following example:

struct B1 {
    int b1;
};
struct B2 {
    int b2;
};
struct D : B1, B2 {
    int d;
};

void clear_D( D *p )
{
    p->d = 0;
    B1 *p1 = p;
    p1->b1 = 0;
    B2 *p2 = p;
    p2->b2 = 0;
}

In this example, the C++ compiler must ensure that p1 and p2 become NULL if p is NULL (since no offset adjustment is allowed for a NULL pointer). However, the first executable statement implies that p isn't NULL since, in most operating environments, the executing program would crash at the first executable statement if it were. The oz option prevents the compiler from omitting the check for a NULL pointer.

The macro __SW_OZ is predefined if oz is selected.

p{e,l,c,w=num}

The input file is preprocessed and, by default, is written to the standard output file. The fo option may be used to redirect the output to a file with default extension .i.

When only p is specified, source comments and #line directives aren't included. You must request these using the c and l suffixes.

Specify pc if you wish to include the original source comments in the Watcom C/C++ preprocessor output file.

(C++ Only) Specify pe if you wish to encrypt the original identifiers when they're written to the Watcom C/C++ preprocessor output file.

Specify pl if you wish to include #line directives. When the output of the preprocessor is fed into the compiler, these directives enable the compiler to issue diagnostics in terms of the line numbers of the original source file.

Specify pcl or plc if you wish both source comments and #line directives.

Use the w=num suffix if you wish to wish output lines to wrap at num columns. Zero means no wrapping.

For example,

wcc report -pclw=80
wpp report -pcelw=80
wcc386 report -pclw=80
wpp386 report -pcelw=80

The following compiler options are supported when the Watcom C/C++ preprocessor is requested: d, fi, fo, i, m{f,s,m,c,l,h}, and u.

r

This option instructs the compiler to generate function prologue and epilogue sequences that save and restore any segment registers that are modified by the function.


Note: Be careful when using this option. If the value of the segment register being restored matches the value of a segment that was freed within the function, a general protection fault occurs in protected-mode environments.

By default, the compiler doesn't generate code to save and restore segment registers. This option is provided for compatibility with the version 8.0 release. The macro __SW_R is predefined if r is selected.

ri

Functions declared to return integral types, such as chars and shorts, are promoted to returning ints. This allows non-ANSI-conforming source code that doesn't properly declare the return types of functions to work correctly.


Note: Avoid using this option; fixing the code is a better idea.

s

Stack overflow checking is omitted from the generated code. By default, the compiler emits code at the beginning of every function that checks for stack overflow. This option can be used to disable this feature.

The macro __SW_S is predefined if s is selected.


Note: QNX interrupt handlers must be compiled with the s and zu options; see the description of the qnx_hint_attach() function in the C Library Reference.

sg

This option is useful for 32-bit OS/2 multi-threaded applications. It requests the code generator to emit a runtime call at the start of any function that has more than 4K bytes of automatic variables (that is, variables located on the stack).

Under 32-bit OS/2, the stack is grown automatically in 4K pages for any threads, other than the primary thread, using the stack guard page mechanism. The stack consists of in-use committed pages topped off with a special guard page. A memory reference into the 4K guard page causes the operating system to grow the stack by one 4K page and to add a new 4K guard page.

This works well when there's less than 4K of automatic variables in a function. When there's more, the stack must be grown in an orderly fashion, 4K bytes at a time, until it's big enough to accommodate all the automatic variable storage requirements. This requires a stack-growing runtime routine, which is called __GRO().

The macro __SW_SG is predefined if sg is selected.


Note: This option doesn't apply to QNX.

st

This option causes the code generator to ensure that the first reference to the stack in a function is to the stack bottom using the SS register. If the memory for this part of the stack isn't mapped to the task, a memory fault occurs, involving the SS register. This permits an operating system to allocate additional stack space to the faulting task.

Suppose that a function requires 100 bytes of stack space. The code generator usually emits an instruction sequence to reduce the stack pointer by the required number of bytes of stack space, thereby establishing a new stack bottom. When the st option is specified, the code generator ensures that the first reference to the stack is to a memory location with the lowest address. If a memory fault occurs, the operating system can determine that it was a stack reference (since the SS register is involved) and also how much additional stack space is required.

See the description of the sg option for a more general solution to the stack allocation problem. The macro __SW_ST is predefined if st is selected.


Note: This option doesn't apply to QNX.

t=num

(C++ only) The t option is used to set the tab stop interval. By default, the compiler assumes a tab stop occurs at multiples of 8 (1+n x 8 = 1, 9, 17, ... for n=0, 1, 2, ...). When the compiler reports a line number and column number in a diagnostic message, the column number has been adjusted for intervening tabs. You should use this option if the default tab stop setting for your text editor isn't a multiple of 8.

For example,

wpp report -t=4
wpp386 report -t=4

uname

The u option turns off the definition of a predefined macro. If no name is specified then all predefined macros are undefined, with the exception of the memory model macros.

For example,

wcc report -uM_I86
wpp report -uM_I86
wcc386 report -uM_I86
wpp386 report -uM_I86

v

This option causes Watcom C to write function declarations to a file with the same filename as the C source file, but with extension .def. This definition file may be used as an include file when compiling other modules, in order to take advantage of the checking that the compiler does on function and argument types. See also the zg option.

wnumber

The compiler issues only warning type messages of severity number or below. Type 1 warning messages are the most severe, while type 3 warning messages are the least. Specify w0 to prevent warning messages from being issued. Specify wx to obtain all warning messages.

wcd=number

This option disables the compiler message with the given number.

wce=number

This option enables the compiler message with the given number.

we

By default, the compiler continues to create an object file when there are warnings produced. This option can be used to treat all warnings as errors, thereby preventing the compiler from creating an object file if there are warnings found within a module.

wo

(16-bit only, C only) This option tells the compiler to emit warnings for things that cause problems when compiling code for use in overlays.

wx

This option sets the warning level to its maximum setting. The wnumber option can be used to set the warning level to other values.

xd, xdt

(C++ only) This option disables exception handling. It's the default option if no exception handling option is specified.


Note: The xd and xdt options are the same.

When this option is specified (explicitly or by default):

  • Destruction of objects is caused by direct calls to the appropriate destructors
  • Destructor functions are implemented with direct calls to appropriate destructors to destroy base classes and class members.

Note: The xd... options disable exception handling. Consequently, it isn't possible to use throw, try, or catch statements, or to specify a function-exception specification. If your program (or a library that it includes) throws exceptions, then one of the xs... options should be used to compile all the modules in your program; otherwise, any active objects created within the module won't be destructed during exception processing.

Multiple schemes are possible, allowing experimentation to determine the optimal scheme for particular circumstances. You can mix and match schemes on a module basis, with the proviso that exceptions should be enabled wherever it's possible that a created object should be destroyed by the exception mechanism.


xds

(C++ only) This option disables exception handling. When this option is specified:

  • Destruction of objects is caused by direct calls to the appropriate destructors.
  • Destruction of base classes and class members is accomplished by interpreting tables.

This option, in general, generates smaller code, with increased execution time, and with more runtime system routines included by the linker.


Note: The xd... options disable exception handling. Consequently, it isn't possible to use throw, try, or catch statements, or to specify a function-exception specification. If your program (or a library that it includes) throws exceptions, then one of the xs... options should be used to compile all the modules in your program; otherwise, any active objects created within the module won't be destroyed during exception processing.

Multiple schemes are possible, allowing experimentation to determine the optimal scheme for particular circumstances. You can mix and match schemes on a module basis, with the proviso that exceptions should be enabled wherever it's possible that a created object should be destroyed by the exception mechanism.


xs

(C++ only) This option enables exception handling using a balanced scheme. When this option is specified:

  • tables are interpreted to effect the destruction of temporaries and automatic objects
  • destructor functions are implemented with direct calls to the appropriate destructors to destroy base classes and class members

xss

(C++ only) This option enables exception handling using a space-saving scheme. When this option is specified:

  • tables are interpreted to effect destruction of temporaries and automatic objects
  • destruction of base classes and class members is accomplished by interpreting tables.

This option, in general, generates smaller code, with increased execution time.

xst

(C++ only) This option enables exception handling using a time-saving scheme. When this option is specified:

  • destruction of temporaries and automatic objects is accomplished with direct calls to appropriate destructors
  • destructor functions are implemented with direct calls to appropriate destructors to destroy base classes and class members.

This scheme, in general, generates faster code, but it uses more space.

za

This option helps to ensure that the module to be compiled conforms to the ANSI C programming language specification. The macro NO_EXT_KEYS (no extended keywords) is predefined if za is selected. See also the description of the ze option.

zc

The zc option causes the code generator to place literal strings and const items in the code segment.

For example,

const int cvar = 1;
int var = 2;
const int ctable[ 5 ] = { 1, 2, 3, 4, 5 };
char *birds[ 3 ] = { "robin", "finch", "wren" };

In the above example, cvar and ctable and the strings ``robin'', ``finch'', and so on are placed in the code segment. This option is supported in large data or flat memory models only, or if the item is explicitly far. The macro __SW_ZC is predefined if zc is selected.

zd{f,p}

The zdf option allows the code generator to use the DS register to point to other segments besides DGROUP. This is the default in the compact, large, and huge (wcc/wpp only) memory models. The macro __SW_ZDF is predefined if zdf is selected.

The zdp option informs the code generator that the DS register must always point to DGROUP. This is the default in the flat (wcc386/wpp386 only), small, and medium memory models. The macro __SW_ZDP is predefined if zdp is selected.

zdl

(wcc386/wpp386 only) The zdl option causes the generation of code to load the DS register directly from DGROUP (rather than the default runtime call). This option causes the generation of a segment relocation. This option is used with the zdp option, but not the zdf option.


Note: QNX flat programs don't allow relocations.

ze

The ze option (default) enables the use of the following compiler extensions:

  • The requirement for at least one external definition per module is relaxed.
  • The escape sequence \l is interpreted as a synonym for \n in strings and character constants.
  • When using the C compiler, some forgiveable pointer type mismatches become warnings instead of errors.
  • In-line math functions are allowed (note that errno won't be set by in-line functions).
  • When using the C compiler, anonymous structs and unions are allowed (this is always permitted in C++).

    For example,

    struct {
        int a;
        union {
            int   b;
            float alt_b;
        };
        int c;
    } x;
        
    

    In the above example, x.b is a valid reference to the b field.

  • For C only, ANSI function prototype scope rules are relaxed to allow the following program to compile without any errors:

    void foo( struct a *__p );
    
    struct a {
        int b;
        int c;
    };
    
    void bar( void )
    {
        struct a x;
        foo( &x );
    }
          
    

    According to a strict interpretation of the ANSI C standard, the function prototype introduces a new scope that's terminated at the semicolon (;). The effect of this is that the structure tag a in the function foo() isn't the same structure tag a defined after the prototype. A diagnostic must be issued for a conforming ANSI C implementation.

  • A trailing comma (,) is allowed after the last constant in an enum declaration.

    For example,

    enum colour { RED, GREEN, BLUE, };
          
    
  • The ANSI requirement that all enumerated types have a base type of int is relaxed. The motivation for this extension is the conservation of storage. Many enumerated types can be represented by integral types that are smaller in size than an int.

    For example,

    enum colour { RED, GREEN, BLUE, };
    
    void foo( void )
    {
        enum colour x;
    
        x = RED;
    }
          
    

    In the example, x can be stored in an unsigned char because its values span the range 0 to 2.

  • The ANSI requirement that the base type of a bitfield be int or unsigned is relaxed. This allows a programmer to allocate bitfields from smaller units of storage than an int (for example, unsigned char).

    For example,

    struct {
        unsigned char a : 1;
        unsigned char b : 1;
        unsigned char c : 1;
    } x;
    
    struct {
        unsigned a : 1;
        unsigned b : 1;
        unsigned c : 1;
    } y;
          
    

    In the above example, the size of x is the same size as an unsigned char, whereas the size of y is the same size as an unsigned int.

  • The following macros are defined:
    • _near, near
    • _far, far
    • _huge, huge
    • _cdecl, cdecl
    • _pascal, pascal
    • _fortran, fortran
    • _interrupt, interrupt
    • _export
    • _loadds
    • _saveregs

    These macros are described in ``C/C++ extended keywords'' in the C/C++ Compilers chapter.

Use the za option if your application must conform to the ANSI C standard.

zf{f,p}

The zff option allows the code generator to use the FS register (the default for all but the flat memory model). The macro __SW_ZFF is predefined if zff is selected.

The zfp option informs the code generator that the FS register must not be used (the default in the flat memory model). The macro __SW_ZFP is predefined if zfp is selected.

zg

The zg option is similar to the v option, except that function declarations are written to the .def file using base types (that is, typedefs are reduced to their base type).

For example,

typedef unsigned int UINT;
UINT f( UINT x )
 {
    return( x + 1 );
 }

If you use the v option, the output is:

extern UINT f(UINT );

If you use the zg option, the output is:

extern unsigned int f(unsigned int );

zg{f,p}

The zgf option allows the code generator to use the GS register (the default for all memory models). The macro __SW_ZGF is predefined if zgf is selected.

The zgp option informs the code generator that the GS register must not be used. The macro __SW_ZGP is predefined if zgp is selected.

zk{0,1,2}

This option causes the compiler to recognize double-byte characters in strings. When the compiler scans a text string enclosed in quotes ("), it recognizes the first byte of a double-byte character, and suppresses the lexical analysis of the second byte. This prevents the compiler from misinterpreting the second byte as a backslash (\) or quote (") character.

zk, zk0
These options cause the compiler to process strings for Japanese double-byte characters (range 0x81 - 0x9F and 0xE0 - 0xFC). The characters in the range A0 - DF are single-byte Katakana.
zk1
This option causes the compiler to process strings for Traditional Chinese and Taiwanese double-byte characters (range 0x81 - 0xFC).
zk2
This option causes the compiler to process strings for Korean Hangeul double-byte characters (range 0x81 - 0xFD).

The macro __SW_ZK is predefined if any zk option is selected.

zk0u

This option causes the compiler to process strings for Japanese double-byte characters (range 0x81 - 0x9F and 0xE0 - 0xFC). The characters in the range A0 - DF are single-byte Katakana. All characters, including Kanji, in wide characters (L'c') and wide strings (L"string") are translated to UNICODE.

When the compiler scans a text string enclosed in quotes ("), it recognizes the first byte of a double-byte character, and suppresses the lexical analysis of the second byte. This prevents the compiler from misinterpreting the second byte as a backslash (\) or quote (") character.

zku=codepage

Characters in wide characters (L'c') and wide strings (L"string") are translated to UNICODE. The UNICODE translation table for the specified code page is loaded from a file with the name UNICODE.cpn, where cpn is the code page number (for example, zku=850 selects the file UNICODE.850).

zl

By default, the compiler places in the object file the names of the C libraries that correspond to the memory model and floating-point options that were selected. The Watcom Linker uses these library names to select the libraries required to link the application. If you use the zl option, the library names aren't included in the generated object file.

The compiler may generate external references for library code that conveniently cause the linker to link in different code. For example, if you have any functions that pass or return floating-point values (that is, float or double), the compiler inserts an external reference that causes the floating-point formatting routines to be included in the executable. The zl option disables these external references.

Use this option when you wish to create a library of object modules that don't contain Watcom C/C++ library name references.

zld

By default, the compiler places in the object file the names and time stamps of all the files referenced by the source file. This file dependency information can then be used by a make utility program to determine that this file needs to be recompiled if any of the referenced files have been modified since the object file was created. This option causes the compiler not to emit this information into the object file.

zm

The zm option instructs the code generator to place each function into a separate segment. This option is used in paging environments where special segment ordering may be employed. The alloc_text pragma is often used in conjunction with this option to place functions into specific segments. The disadvantages to this option are:

  1. Static functions are far-called in big code models. The near-call optimization is lost.
  2. The common-epilogue optimization is lost.

The macro __SW_ZM is predefined if zm is selected.

zo

This option enables exception handling using a space-saving scheme.

This option has been added to the C++ compiler in order to specify that operating-system dependent exception-handling is to be used. When the option isn't specified, the exception-handling mechanism is independent of the operating system (as was the case in previous releases).


Note: This option has an effect only under NT and OS/2 in the 32-bit compiler (WPP386). A warning is issued when this option is used in other environments.

When this option is used, it must be used to produce all C++ object files that are linked together to create .EXE or .DLL files. When only some of the object files are compiled with this option, the linker will report unresolved or duplicated global symbols. If you wish to use this option, the complete application must be recompiled with this option. This is to ensure that only operating-system dependent libraries are used to link the application.

When the zo option is used and the target object is for a different system than the system used for compilation, the build-target (bt) option must be used to specify the target system. If omitted, the C++ compiler assumes you're producing object for the system used to compile the program.

This option should viewed as a temporary mechanism to allow users to avoid recompiling applications when they don't require either NT or OS/2 system exception handling. In the next major release, full recompilation will be required and the system-dependent exception handling will be the default.

To help resolve errors, the following global symbols are generated:

__compiled_under_NT
compiled using -zo -bt=NT
__compiled_under_OS2
compiled using -zo -bt=OS2
__compiled_under_GENERIC
compiled otherwise. This is defined in all libraries for which exceptions are handled in a system-independent manner.

zp[{1,2,4,8}]

The zp option allows you to specify the alignment of members in a structure. The default is zp1. The alignment of structure members is described in the following table. If the size of the member is 1, 2, 4 or 8, the alignment is given for each of the zp options.

sizeof(member)zp1zp2zp4zp8
10000
20222
40244
80248

An alignment of 0 means no alignment, 2 means word boundary, 4 means double-word boundary, and so on.

If the member of the structure is an array or structure, it's aligned to the largest member, as follows:

  • If the largest member of structure x is 1 byte, then x isn't aligned.
  • If the largest member of structure x is 2 bytes, then x is aligned according to row 2.
  • If the largest member of structure x is 4 bytes, then x is aligned according to row 4.
  • If the largest member of structure x is 8 bytes, then x is aligned according to row 8.

To understand why the alignment of structure members may be important, consider the following example:

typedef struct memo_el {
    char           date[9];
    struct memo_el *prev,*next;
    ref_number     int;
} memo;

In the above example, the default alignment zp1 causes the pointer and integer items to be aligned on odd addresses, since the array date is 9 bytes in length. On computer systems that have a 16-bit (or 32-bit) bus, improved performance can be obtained when these items are aligned on an even boundary.

zq

The quiet mode option causes the informational messages displayed by the compiler to be suppressed. These include:

  • messages that identify the compiler
  • messages that summarize the number of lines compiled
  • dots that are displayed every few seconds while the code generator is active to indicate that the compiler is still working.

Error and warning messages aren't suppressed.

zs

This option makes the compiler check the source code only, and omit the generation of object code. Syntax checking, type checking, and so on are performed as usual.

ztnumber

The data threshold option is used to set the maximum size for data objects to be included in the default data segment. This option can be used with the compact, large, and huge (16-bit) memory models only. These are memory models where there can be more than one data segment.

Normally, all data objects whose size is less than or equal to the threshold value are placed in the default data segment _DATA unless they're specifically declared to be far items. When there's a large amount of static data, it's often useful to set the data threshold size so that all objects larger than this size are placed in another (far) data segment.

For example, the option zt100 causes all data objects larger than 100 bytes in size to be implicitly declared as far, and to be grouped in other data segments.

The default data threshold value is 32767. Thus, by default, all objects greater than 32767 bytes in size are implicitly declared as far, and are placed in other data segments. If the zt option is specified without a size, the data threshold value is 256.


Note: If the zt option is used to compile any module in a program, then you must compile all the other modules in the program with the same option (and value).

Be careful when declaring the size of objects in different modules. Consider the following declarations in two different C files. Suppose we define an array in one module as follows:

extern int Array[100] = { 0 };

and, suppose we reference the same array in another module as follows:

extern int Array[10];

If these modules are compiled with the option zt100, we have a problem. In the first module, the array would be placed in another segment, since Array[100] is bigger than the data threshold. In the second module, the array would be placed in the default data segment since Array[10] is smaller than the data threshold. The extra code required to reference the object in another data segment wouldn't be generated.


Note: This problem can also occur even when the zt option isn't used (that is, for objects greater than 32767 bytes in size). There are two solutions to this problem:
  • be consistent when declaring an object's size, or,
  • don't specify the size in data reference declarations.

zu

The zu option relaxes the restriction that the SS register contains the base address of the default data segment, DGROUP. Normally, all data items are placed into the group DGROUP, and the SS register contains the base address of this group. When the zu option is selected, the SS register is volatile (that is, it's assumed to point to another segment), and any global data references require loading a segment register such as DS with the base address of DGROUP.

This option is useful when compiling routines that are to be placed in a shared library, since the SS register points to the stack segment of the calling application upon entry to the function.

The macro __SW_ZU is predefined if zu is selected.


Note: QNX interrupt handlers must be compiled with the s and zu options; see the description of the qnx_hint_attach() function in the C Library Reference.

zv

This option makes sizeof (void) == 1, so you can directly increment or decrement void pointers without having to do type-casting.

zw

(wcc/wpp only) This option causes the compiler to generate the prologue/epilogue code sequences required for Microsoft Windows applications. The following ``fat'' prologue/epilogue sequence is generated for any functions declared to be far _export or far pascal.

far pascal func(...)
far _export func(...)
far _export pascal func(...)

    push DS
    pop  AX
    nop
    inc  BP
    push BP
    mov  BP,SP
    push DS
    mov  DS,AX
    .
    .
    .
    pop DS
    pop BP
    dec BP
    retf n

The macro __WINDOWS__ is predefined if zw is selected.

(wcc386/wpp386 only) This option causes the compiler to generate any special code sequences required for 32-bit Microsoft Windows applications. The macro __WINDOWS__ and __WINDOWS_386__ are predefined if zw is selected.


Note: This option doesn't apply to QNX.

zW

(wcc/wpp only) This option is similar to zw, but causes the compiler to generate more efficient prologue/epilogue code sequences in some cases. This option may be used for Microsoft Windows applications code other than user callback functions. Any functions declared as far _export are compiled with the ``fat'' prologue/epilogue code sequence described under the zw option.

far _export func(...)
far _export pascal func(...)

The following ``skinny'' prologue/epilogue sequence is generated for functions that aren't declared to be far _export.

far pascal func(...)
far func(...)

    inc  BP
    push BP
    mov  BP,SP
    .
    .
    .
    pop BP
    dec BP
    retf n

The macro __CHEAP_WINDOWS__ and __WINDOWS__ are predefined if zW is selected.


Note: This option doesn't apply to QNX.

zWs

(wcc/wpp only) This option is similar to zW, but causes the compiler to generate ``smart callbacks.'' This option may be used for Microsoft Windows user callback functions in executables only. It isn't permitted for DLLs.


Note: This option doesn't apply to QNX.

Normally, a callback function can't be called directly. You must use MakeProcInstance() to obtain a function pointer with which to call the callback function.

If you specify zWs then you don't need to use MakeProcInstance() in order to call your own callback functions. Any functions declared as far _export are compiled with the ``smart'' prologue code sequence described here.

The following example shows the usual prologue code sequence that's generated when the zWs option isn't used.

wcc winapp -mc -bt=windows -d1
wpp winapp -mc -bt=windows -d1

short FAR PASCAL __export Function1( short var1,
                                     long varlong,
                                     short var2 )
{
 0000  1e         FUNCTION1          push    ds
 0001  58                            pop     ax
 0002  90                            nop
 0003  45                            inc     bp
 0004  55                            push    bp
 0005  89 e5                         mov     bp,sp
 0007  1e                            push    ds
 0008  8e d8                         mov     ds,ax

The following example shows the ``smart'' prologue code sequence that's generated when the zWs option is used. The assumption here is that the SS register contains the address of DGROUP.

wcc winapp -mc -bt=windows -d1 -zWs
wpp winapp -mc -bt=windows -d1 -zWs

short FAR PASCAL __export Function1( short var1,
                                     long varlong,
                                     short var2 )
{
 0000  8c d0         FUNCTION1       mov     ax,ss
 0002  45                            inc     bp
 0003  55                            push    bp
 0004  89 e5                         mov     bp,sp
 0006  1e                            push    ds
 0007  8e d8                         mov     ds,ax

zz

Use this option if you want to generate __stdcall function names that are compatible with version 10.0 of the compilers. When this option is omitted, all C symbols (extern C symbols in C++) are suffixed by @nnn, where nnn is the sum of the argument sizes (each size is rounded up to a multiple of 4 bytes so that char and short are size 4). When the argument list contains ``...'', the @nnn suffix is omitted. This convention is compatible with Microsoft.

For more information on the __stdcall convention, see ``Watcom Extended Keywords'' in the C/C++ Compilers chapter.


Note: This option doesn't apply to QNX.