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 can control different aspects of your application, such as:
See the Option Categories section for the option capabilities included with the Intel® C++ Compiler Classic.
When you specify compiler options on the command line, the following syntax applies:
// Linux and macOS* [invocation] [options] [@response_file] file1 [file2...]
The invocation is icc.
The options represents zero or more compiler options and the file is any of the following:
When compiling C language sources, invoke the compiler with icc. When compiling C++ language sources or a combination of C and C++, invoke the compiler with icpc.
When you specify compiler options on the command line, the following syntax applies:
[invocation] [options] [@response_file] file1 [file2 ...] [/link linker_options]
The invocation is icc.
The options represents zero or more compiler options, the linker_options represents zero or more linker options, and the file is any of the following:
The optional response_file is a text file that lists the compiler options you want to include during compilation. See Using Response Files for additional information.
The compiler invokes many options by default. In this example, the compiler includes the option O2 (and other default options) in the compilation:
// Linux and macOS* [invocation] main.c
// Windows [invocation] main.c
The invocation is icc.
Each time you invoke the compiler, options listed in the corresponding configuration file override any competing default options. For example, if your configuration file includes the O3 option, the compiler uses O3 rather than the default O2 option. Use the configuration file to list the options for the compiler to use for every compilation. See Using Configuration Files.
Options specified in the command line environment variable override any competing default options and options listed in the configuration file.
Finally, options used on the command line override any competing options that may be specified elsewhere (default options, options in the configuration file, and options specified in the command line environment variable). If you specify the option O1 on the command line, this option setting takes precedence over competing option defaults and competing options in the configuration files, in addition to the competing options in the command line 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, the O3 is listed in the configuration file, and the O1 is specified on the command line for the rest of the program.
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. For example:
For C:// Linux and macOS*
icc –xSSSE3 main.c file1.c –xSSE4.2 file2.c
// Windows
icl /QxSSSE3 main.c file1.c /QxSSE4.2 file2.c
For C++:
// Linux and macOS*
icpc –xSSSE3 main.c file1.c –xSSE4.2 file2.c
// Windows
icl /QxSSSE3 main.c file1.c /QxSSE4.2 file2.c
The compiler sees [Q]xSSSE3 and [Q]xSSE4.2 as two forms of the same option, where only one form can be used. Since [Q]xSSE4.2 is last (furthest to the right), it will be used.
All options specified on the command line are used to compile each file. The compiler does not compile individual files with specific options. For example:
// Linux and macOS* icc -O3 main.c file1.c -mp1 file2.c
// Windows icl /O3 main.c file1.c /Qprec file2.c
It may seem that main.c and file1.c are compiled with the option O3, and file2.c is compiled with the -mp1 (Linux and macOS*) or /Qprec (Windows) option. This is not correct; all files are compiled with both options.
A rare exception to this rule is the -x type option:
For C:
// Linux and macOS*
icc -x c file1 -x c++ file2 -x assembler file3
For C++:
// Linux and macOS*
icpc -x c file1 -x c++ file2 -x assembler file3
The type argument identifies each file type for the compiler.
Compiler options can be as simple as a single letter, such as the option E. 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 warns you if your option and argument are not recognized. If you specify O9, the compiler issues a warning, ignores the unrecognized option O9, and proceeds with the compilation.
The O option does not require an argument, but 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 its compilation.
You can toggle some options on or off by using the negation convention. For example, the [Q]ipo option (and many others) includes negation forms, -no-ipo (Linux and macOS*) and /Qipo- (Windows), to change the state of the option.
When you invoke the Intel® C++ Compiler Classic and specify a compiler option, you have a wide range of choices to influence the compiler's default operation. Intel® C++ Compiler Classic options typically correspond to one or more of the following categories:
To see the included options in each category, invoke the compiler from the command line with the help category option. For example:
//Linux and macOS*
icc -help codegen
//Windows
icc /help codegen
The help option prints to stdout with the names and syntax of the options found in the Code Generation category.