Intel® C++ Compiler XE 13.1 User and Reference Guides
To build your application for static analysis in Microsoft Visual Studio, use the Build for Intel Static Analysis menu option. This creates a new build configuration for static analysis and sets the required properties in the Visual Studio IDE.
There are several forms of the Build for Intel Static Analysis menu option, including:
The first time you use this menu option, a dialog box appears to guide you through the setup process.
Using Static Analysis for an Intel C++ Solution
To perform static analysis on Intel C++ solutions and projects:
Analysis results will open automatically in the Intel® Inspector XE user interface.
Using Static Analysis for a Visual C++ Solution or a Mixed Solution
To perform static analysis on Visual C++ only solutions and projects or on a mixed solution containing both Intel C++ and Visual C++ projects, do the following::
Existing configurations will not be modified. The Solution Explorer will show a different icon to indicate that a project configuration is built by the Intel compiler.
Analysis results will open automatically in the Intel® Inspector XE user interface.
Preparing a Visual C++ project for use with static analysis does not cause the existing configurations to build with the Intel compiler. However, it does modify the solution (.sln) file and adds an Intel project (.icproj) file for each prepared project. After these changes, the solution will no longer build on systems where the Intel compiler is not installed. In a team environment where some team members will not install the Intel compiler, it is best to treat these modifications as temporary and discard them after running static analysis. You can always use the menu item to perform the preparation step again as needed.
There are several Microsoft Visual Studio* IDE property pages related to static analysis. You can change the options for static analysis by modifying the properties for the Intel_SSA configuration. To do this, use the following property pages:
In the Eclipse* IDE:
Open the property pages for the project and select C/C++ Build .
Click the Manage… button.
In the Manage dialog box, click the New… button to open the Create configuration dialog box.
Supply a name for the new configuration in the Name box; for example, Intel_SSA.
Supply a Description for the configuration if you want (optional).
Choose Copy settings from an existing configuration and click the appropriate radio button to select the Debug configuration from the corresponding drop down menu.
Click OK to close the Create configuration dialog box.
Click OK to close the Manage dialog box (with your new configuration name selected).
Navigate to the Intel compiler's Compilation Diagnostics properties.
Use the Level of Static Analysis and Analyze Include Files properties to enable static analysis.
If you are building from the command line, you need to create a new build configuration or target distinct from your existing build configuration or target. Once you do this, you can add the command line options to enable static analysis. You must supply the options that request static analysis on each compilation and link step. The following table summarizes the static analysis options. See the Compiler Options reference for full descriptions of each option.
|
Option (Windows* and Linux* OS syntax) |
Result |
|---|---|
|
/Qdiag-enable:sc{[1|2|3]} -diag-enable sc{[1|2|3]} |
Enables static analysis. The number specifies the severity level of diagnostics reported (1=only critical errors, 2=all errors and warnings, and 3=all diagnostics regardless of severity level). |
|
/Qdiag-enable:sc-{full|concise|precise} -diag-enable sc-{full|concise|precise} |
Enables static analysis and determines the analysis mode. |
|
/Qdiag-disable:sc -diag-disable sc |
Disables static analysis |
|
/Qdiag-enable:sc-include -diag-enable sc-include |
Analyzes system include files as well as source files. By default, apparent errors in system include files are not reported. System include files are those include files found using the INCLUDE environment variable. |
|
/Qdiag-enable:sc-single-file -diag-enable sc-single-file |
Processes each file individually, skipping the usual whole-program analysis. This reduces memory requirements and analysis time on large programs, but may detect fewer real errors. |
|
/Qdiag-sc-dir:dir -diag-sc-dir dir |
Directs diagnostic results to the given directory. If this option is not specified, or if the option is specified without indicating a directory, results are directed to the current working directory. Each run creates results in a new subdirectory whose name has the form "r@@@sc", where "@@@" is replaced the next available sequence number (001, 002, ...). This option requires that you also specify the compiler option to enable static analysis. |
|
/Qdiag-enable:sc-enums -diag-enable sc-enums |
Instructs static analysis to treat enumeration variables as known values equal to any one of the associated enumeration literals. By default, static analysis treats unknown enumeration variables as unknown integer values. Setting this option may find additional errors, but tends to create more false positives. |
Windows* OS: Even if your project must build on the command line, it is still possible to integrate your project into Visual Studio. To do this, create a Visual Studio "makefile project," in which case, Visual Studio will build the project by invoking a command line of your choosing. If you plan to use a makefile project, you should add the /Qdiag-sc-dir:dir or -diag-sc-dir dir option on the link step to direct the output to the "My Inspector XE Results-<product name>" folder in the project root directory. This allows Intel® Inspector XE to find your results and display them in the Visual Studio Solution Explorer. If you do not want to use Visual Studio at all, you should use the stand-alone form of the Intel® Inspector XE GUI. If you do this, you can place your results wherever you like.
To enable OpenMP*, specify the /Qopenmp (Windows* OS) or -openmp (Linux* OS) option. You must do this if your program uses OpenMP.
Using Build Specifications: As an alternative to creating a new build configuration, you can create a build specification. See Creating and Using Build Specification Files for more information.
Static analysis results are generated at the link step. The Intel linker must be used for linking and the compiler driver automatically invokes the Intel linker when building an executable. On Windows* OS, you must build static libraries with the Intel librarian, xilib.exe. The xilib program recognizes the static analysis compiler options such as /Qdiag-enable:sc{1|2|3}. If you supply an option that enables static analysis, you can generate a static analysis result for the static library. On Linux* OS, you must build the static library for static analysis with the Intel archive program, xiar. If you want to generate a static analysis result for the static library, you need to use xiar and supply the static analysis compiler options such as -diag-enable=sc{1|2|3} but preceded by a "q", for example, -qdiag-enable=sc3.