Go to main content
Oracle® Developer Studio 12.6: C++ User's Guide

Exit Print View

Updated: July 2017

3.5 User-Supplied Default Options File

The default compiler options file enables the user to specify a set of default options that are applied to all compiles, unless otherwise overridden. For example, the file could specify that all compiles default at —xO2, or automatically include the file setup.il.

At startup, the compiler searches for a default options file listing default options it should include for all compiles. The environment variable SPRO_DEFAULTS_PATH specifies a colon separated list of directories to search for the defaults file.

If the environment variable is not set, a standard set of defaults is used. If the environment variable is set but is empty, no defaults are used.

The defaults file name must be of the form compiler.defaults, where compiler is one of the following: cc, c89, c99, CC, ftn, or lint. For example, the defaults for the C++ compiler would be CC.defaults

If a defaults file for the compiler is found in the directories listed in SPRO_DEFAULTS_PATH, the compiler will read the file and process the options prior to processing the options on the command line. The first defaults file found will be used and the search terminated.

System administrators may create system-wide default files in Studio-install-path/lib/compilers/etc/config. If the environment variable is set, the installed defaults file will not be read.

The format of a defaults file is similar to the command line. Each line of the file may contain one or more compiler options separated by white space. Shell expansions, such as wild cards and substitutions, will not be applied to the options in the defaults file.

The value of the SPRO_DEFAULTS_PATH and the fully expanded command line will be displayed in the verbose output produced by options —#, —###, and —dryrun.

Options specified by the user on the command line will usually override options read from the defaults file. For example, if the defaults file specifies compiling with —xO4 and the user specifies —xO2 on the command line, —xO2 will be used.

Some options appearing in the default options file will be appended after the options specified on the command line. These are the preprocessor option —I, linker options —B, —L, —R, and —l, and all file arguments, such as source files, object files, archives, and shared objects.

The following is an example of how a user-supplied default compiler option startup file might be used.

demo% cat /project/defaults/CC.defaults
-I/project/src/hdrs —L/project/libs —llibproj —xvpara
demo% setenv SPRO_DEFAULTS_PATH  /project/defaults
demo% CC —c —I/local/hdrs —L/local/libs —lliblocal tst.c

This command is now equivalent to:

CC -fast —xvpara —c —I/local/hdrs —L/local/libs —lliblocal tst.c \ 
     —I/project/src/hdrs —L/project/libs —llibproj

While the compiler defaults file provides a convenient way to set the defaults for an entire project, it can become the cause of hard to diagnose problems. Set the environment variable SPRO_DEFAULTS_PATH to an absolute path rather than the current directory to avoid such problems.

The interface stability of the default options file is uncommitted. The order of option processing is subject to change in a future release.