Developer Guide and Reference

Contents

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 can control different aspects of your application, such as:
  • Code generation
  • Optimization
  • Output file (type, name, location)
  • Linking properties
  • Size of the executable
  • Speed of the executable
See the Option Categories section for the option capabilities included with the
Intel® oneAPI
DPC++/C++
Compiler
.

Command Line Syntax (Linux*)

When you specify compiler options on the command line, the following syntax applies:
// Linux [invocation] [options] [@response_file] file1 [file2...]
The
invocation
is
icx
for C,
icpx
for C++, or
dpcpp
for DPC++
.
The
options
represents zero or more compiler options and the
file
is any of the following:
  • C or C++ source file (
    .C
    ,
    .c
    ,
    .cc
    ,
    .cpp
    ,
    .cxx
    ,
    .c++
    ,
    .i
    ,
    .ii
    )
  • Assembly file (
    .s
    ,
    .S
    )
  • Object file (
    .o
    )
  • Static library (
    .a
    )
When compiling C language sources, invoke the compiler with
icx
. When compiling C++ language sources or a combination of C and C++, invoke the compiler with
icpx
.
When compiling DPC++ sources, invoke the compiler with
dpcpp
.

Command Line Syntax (Windows*)

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
icx
for C/C++, or
dpcpp-cl
for DPC++
.
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:
  • C or C++ source file (
    .c
    ,
    .cc
    ,
    .ccp
    ,
    .cxx
    ,
    .i
    )
  • Assembly file (
    .asm
    )
  • Object (
    .obj
    )
  • Static library (
    .lib
    )
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 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 icx –xSSSE3 main.c file1.c –xSSE4.2 file2.c
// Windows icx /QxSSSE3 main.c file1.c /QxSSE4.2 file2.c
For C++:
// Linux icpx –xSSSE3 main.c file1.c –xSSE4.2 file2.c
// Windows icx /QxSSSE3 main.c file1.c /QxSSE4.2 file2.c
For DPC++:
// Linux dpcpp -O1 main.c file1.c -O2 file2.c
// Windows dpcpp-cl /O1 main.c file1.c /O2 file2.c
The compiler sees
[Q]xSSSE3
(for C/C++) or
O1
(for DPC++) and
[Q]xSSE4.2
(for C/C++) or
O2
(for DPC++) as two forms of the same option, where only one form can be used. Since [
Q]xSSE4.2
(for C/C++) or
O2
(for DPC++) are last (furthest to the right), they are used.
All options specified on the command line are used to compile each file. The compiler does not compile individual files with specific options.
A rare exception to this rule is the
-x
type
option:
For C:
// Linux icx -x c file1 -x c++ file2 -x assembler file3
For C++:
// Linux icpx -x c file1 -x c++ file2 -x assembler file3
For DPC++:
// Linux dpcpp -x c++-header file1 -x c++ file2
The
type
argument identifies each file type for the compiler.

Default Operation

The compiler invokes many options by default. In this example, the compiler includes the option
O2
(and other default options) in the compilation:
// Linux [invocation] main.c
// Windows [invocation] main.c
The
invocation
is
icx
for C,
icpx
for C++, or
dpcpp
for DPC++ for Linux projects and
icx
for C/C++, or
dpcpp-cl
for DPC++ for Windows projects.
.
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.
The default
.cfg
files are not valid for the
Intel oneAPI
DPC++/C++
Compiler
. You can use the
-config<name>
option instead of a default
.cfg
file.
<name>
can be a configuration file that is in the
bin
directory, or you can use the full path your selected
.cfg
file.
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.

Using Options with Arguments

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.

Other Forms of Options

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
/Qipo-
(Windows)
, to change the state of the option.

Option Categories

When you invoke the
Intel oneAPI
DPC++/C++
Compiler
and specify a compiler option, you have a wide range of choices to influence the compiler's default operation.
Intel oneAPI
DPC++/C++
Compiler
options typically correspond to one or more of the following categories:
  • Advanced Optimization
  • Code Generation
  • Compatibility
  • Compiler Diagnostics
  • Component Control
    This content is specific to C++; it does not apply to
    DPC++
    .
  • Data
  • Floating Point
    This content is specific to C++; it does not apply to
    DPC++
    .
  • Inlining
  • Interprocedural Optimizations (IPO)
  • Language
  • Linking/Linker
  • Miscellaneous
  • OpenMP* and
    Parallel Processing
  • Optimization
  • Output
  • Preprocessor
This content is specific to C++; it does not apply to
DPC++
.
To see the included options in each category, invoke the compiler from the command line with the
help
category option. For example:
//Linux icx -help codegen
//Windows icx /help codegen
The help option prints to
stdout
with the names and syntax of the options found in the Code Generation category.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.