Appendix: Use of Environment Variables

In the Watcom C/C++ software development package, a number of environment variables are used:

This appendix summarizes their use with a particular component of the package.

FORCE

The FORCE environment variable identifies a file that's to be included as part of the source input stream. This variable is used by Watcom C/C++.

export "FORCE=filespec"

The specified file is included as if a

#include "filespec"

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

export "FORCE=/usr/include/common.cnv"
wcc report

The FORCE environment variable can be overridden by use of the Watcom C/C++ compiler fi option.

INCLUDE

The INCLUDE environment variable describes the location of the C and C++ header files (files with the .h filename extension). This variable is used by Watcom C/C++.

export "INCLUDE=path:path..."

The INCLUDE environment string is like the PATH string, in that you can specify one or more directories separated by colons (:).

LIB

The LIB environment variable is used to select the libraries that are used when the application is linked. This variable is used by the Watcom Linker (wlink). The LIB environment string is like the PATH string, in that you can specify one or more directories separated by colons (:).

We recommend that you use the WATCOM environment variable and the Watcom Linker SYSTEM directive instead of this environment variable.

PATH

The PATH environment variable is used by the QNX shell to locate programs.

export "PATH=path:path..."

The PATH environment variable should include the directory of the Watcom C/C++ binary program files when using Watcom C/C++ and its related tools.

The default installation directory for Watcom C/C++ QNX binaries is called /bin.

For example,

export "PATH=/bin"

The PATH environment variable is also used by:

  • cc to locate the 16-bit Watcom C/C++ and 32-bit Watcom C/C++ compilers and the Watcom Linker.
  • wd to locate programs.

TMPDIR

The TMPDIR environment variable describes the location (path) for temporary files created by the 16-bit Watcom C/C++ and 32-bit Watcom C/C++ compilers and the Watcom Linker.

export "TMPDIR=path"

Normally, 16-bit Watcom C/C++ and 32-bit Watcom C/C++ create temporary spill files in the current directory. However, by defining the TMPDIR environment variable to be a certain path, you can tell Watcom C/C++ where to place its temporary files. The same is true of the Watcom Linker temporary file.

Consider the following definition of the TMPDIR environment variable:

export "TMPDIR=//2/hd/tmp"

The Watcom C/C++ compiler and Watcom Linker create their temporary files in //2/hd/tmp.

WATCOM

In order for the Watcom Linker to locate the 16-bit Watcom C/C++ and 32-bit Watcom C/C++ library files, the WATCOM environment variable should be defined.

When using cc, it isn't necessary to define this environment variable, since it uses another technique for identifying the location of the library files to the Watcom Linker. However, you should do so when you begin to use the Watcom Linker directly without the aid of this utility program.

The WATCOM environment variable is used to locate the libraries that are used when the application is linked. The default directory for 16-bit Watcom C/C++ and 32-bit Watcom C/C++ files is /usr.

For example,

export "WATCOM=//0/hd/usr"

WCC

The WCC environment variable can be used to specify commonly used options for the 16-bit C compiler.

export "WCC=-option1 -option2 ..."

These options are processed before options specified on the command line. The following example defines the default options to be d1 (include line number debug information in the object file) and ox (compile for maximum number of code optimizations):

export "WCC=-d1 -ox"

Once the WCC environment variable has been defined, those options listed become the default each time the wcc command is used.

WCC386

The WCC386 environment variable can be used to specify commonly used options for the 32-bit C compiler.

export "WCC386=-option1 -option2 ..."

These options are processed before options specified on the command line. The following example defines the default options to be d1 (include line number debug information in the object file) and ox (compile for maximum number of code optimizations):

export "WCC386=-d1 -ox"

Once the WCC386 environment variable has been defined, those options listed become the default each time the wcc386 command is used.

WCGMEMORY

The WCGMEMORY environment variable may be used to request a report of the amount of memory used by the compiler's code generator for its work area.

export "WCGMEMORY=?"

When the memory amount is ``?'', then the code generator reports how much memory was used to generate the code.

It may also be used to instruct the compiler's code generator to allocate a fixed amount of memory for a work area. For example,

export "WCGMEMORY=128"

When the memory amount is nnn then exactly nnnK bytes are used. In the above example, 128K bytes is requested. If less than nnnK is available then the compiler quits with a fatal error message. If more than nnnK is available then only nnnK bytes are used.

This feature can be quite useful. In general, the more memory available to the code generator, the more optimal code it generates. Thus, for two personal computers with different amounts of memory, the code generator may produce different (although correct) object code.

If you have a software quality assurance requirement that the same results (that is, code) be produced on two different machines, then you should use this feature. To generate identical code on two personal computers with different memory configurations, you must ensure that the WCGMEMORY environment variable is set identically on both machines.

WD

The WD environment variable can be used to specify commonly used Watcom Debugger options.

export "WD=-option1 -option2 ..."

These options are processed before options specified on the command line. The following example defines the default options to be noinvoke (don't execute the profile.dbg file) and reg=10 (retain up to 10 register sets while tracing):

export "WD=-noinvoke -reg=10"

Once the WD environment variable has been defined, those options listed become the default each time the wd command is used.

WD_PATH

The WD_PATH environment variable is used by WD to locate Watcom Debugger support files. These files fall into five categories:

  • command files (files with the .dbg extension)
  • trap files (files with the .trp extension)
  • parser files (files with the .prs extension)
  • help files (files with the .hlp extension)
  • symbolic debugging information files (files with the .sym extension)

For example,

export "WD_PATH=path:path..."

By default, the Watcom Debugger looks in the /usr/watcom/wd directory for command files, so it isn't necessary to include this directory in the WD_PATH environment variable string.

WLIB

The WLIB environment variable can be used to specify commonly used Watcom Library Manager options.

export "WLIB=-option1 -option2 ..."

These options are processed before options specified on the command line. The following example defines the default options to be -n (always create a new library) and -c (use case-sensitive comparison for symbol names):

export "WLIB=-n -c"

Once the WLIB environment variable has been defined, those options listed become the default each time the wlib command is used.

WPP

The WPP environment variable can be used to specify commonly used options for the 16-bit C++ compiler.

export "WPP=-option1 -option2 ..."

These options are processed before options specified on the command line. The following example defines the default options to be d1 (include line number debug information in the object file) and ox (compile for maximum number of code optimizations):

export "WPP=-d1 -ox"

Once the WPP environment variable has been defined, those options listed become the default each time the wpp command is used.

WPP386

The WPP386 environment variable can be used to specify commonly used options for the 32-bit C++ compiler.

export "WPP386=-option1 -option2 ..."

These options are processed before options specified on the command line. The following example defines the default options to be d1 (include line number debug information in the object file) and ox (compile for maximum number of code optimizations):

export "WPP386=-d1 -ox"

Once the WPP386 environment variable has been defined, those options listed become the default each time the wpp386 command is used.