Using Compiler Options

A compiler option is a case-sensitive, command-line expression used to change the compiler's default operation. Compiler options are not required to compile your program, but they are extremely useful in helping you control different aspects of your application, such as:

See Option Categories below for a broader view of the option capabilities included with the Intel® C++ Compiler.

Command-line Syntax

When you specify compiler options on the command-line, the following syntax applies:

icc [options] [@response_file] file1 [file2...]

where options represents zero or more compiler options

where file is any of the following:

If you are compiling just C language sources, invoke the compiler with icc. You should invoke the compiler with icpc if you are compiling just C++ language sources or a combination of C and C++.

The optional response_file is a text file that lists compiler options you want to include during compilation. See Using Response Files.

The compiler reads command-line options from left to right. If your compilation includes competing options, then the compiler uses the one furthest to the right. In other words, "the last one wins." In this example:

icc -xP main.c file1.c -xW file2.c

the compiler sees -xP and -xW as two forms of the same option where only one form can be used. Since -xW is last (furthest to the right), it wins.

All options specified on the command line are used to compile each file. The compiler will NOT compile individual files with specific options as this example may suggest:

icc -O3 main.c file1.c -mp1 file2.c

It may seem that main.c and file1.c are compiled with -O3, and file2.c is compiled with the -mp1 option. This is not the case. All files are compiled with both options.

A rare exception to this general rule is the -x type option:

icc -x c file1 -x c++ file2 -x assembler file3

where the type argument identifies each file type for the compiler.

Default Operation

The compiler invokes many options by default. For example, the -O2 option is on by default for systems based on IA-32 architecture. In this simple example, the compiler includes -O2 (and the other default options) in the compilation:

icc main.c

See the Compiler Options reference for the default status of each compiler option.

Each time you invoke the compiler, options listed in the corresponding configuration file (icc.cfg or icpc.cfg) override any competing default options. For example, if your icc.cfg file includes the -O3 option, the compiler will use -O3 rather than the default -O2 option. Use the configuration file to list options you'd like the compiler to use for every compilation. See Using Configuration Files.

Finally, options used on the command-line override any competing options specified elsewhere (default options, options in the configuration file). If you specify -O1 on the command line, this option setting would "win" over competing option defaults and competing options in configuration files, in addition to competing options in the CL environment variable.

Certain #pragma statements in your source code can override competing options specified on the command line. For example, if a function in your code is preceded by #pragma optimize("", off), then optimization for that function is turned off, even though -O2 optimization is on by default, -O3 is listed in the configuration file, and -O1 is specified on the command-line for the rest of the program.

Using Options with Arguments

Compiler options can be as simple as a single letter, such as -E/E. However, many options accept or require arguments. The -O option, for example, accepts a single-value argument that the compiler uses to determine the degree of optimization. Other options require at least one argument and can accept multiple arguments. For most options that accept arguments, the compiler will warn you if your option and argument are not recognized. If you specify -O9, for example, the compiler will issue a warning, ignore the unrecognized -O9 option, and proceed with compilation.

While the -O option does not require an argument, there are other options that must include an argument. The -I option requires an argument that identifies the directory to add to the include file search path. If you use this option without an argument, the compiler will not finish compilation.

See the Compiler Options reference for a complete description of options and their supported arguments.

Other Forms of Options

You can toggle some options on or off by using the negation convention. For example, the -complex-limited-range option, and many others, include a negation form, -no-complex-limited-range, to change the state of the option. Since this option is disabled by default, using -complex-limited-range on the command line would toggle it to the "ON" state.

Option Categories

When you invoke the Intel C++ Compiler and specify a compiler option, you have a wide range of choices to influence the compiler's default operation. Intel compiler options typically correspond to one or more of the following categories:

To see which options are included in each category, invoke the compiler from the command line with the -help category option. For example:

icc -help codegen

will print to stdout the names and syntax of the options in the Code Generation category.


Submit feedback on this help topic

Copyright © 1996-2011, Intel Corporation. All rights reserved.