Compiler (-compiler)
Specify the compiler that you use to build your source code
Description
This page lists the compilers supported with the static analysis products, Polyspace® Bug Finder™ and Polyspace Code Prover™. For information on the compilers supported with Polyspace Test™, see Specify C/C++ Compilers for Testing in Polyspace Platform User Interface (Polyspace Test).
Specify the compiler that you use to build your source code.
Polyspace fully supports the most common compilers used to develop embedded
applications. See the list below. For these compilers, you can run analysis simply by
specifying your compiler and target processor. For other compilers, specify
generic as compiler name. If you face compilation errors,
explicitly define compiler-specific extensions to work around the errors.
Set Option
Set the option using one of these methods:
Polyspace user interface (desktop products only) — In your project configuration, select the Target & Compiler node and then select a value for this option.
Polyspace Platform user interface (desktop products only) — See
Compilation toolchain (Static Analysis).Command line and options file — Use the option
-compiler. See Command-Line Information.
Why Use This Option
Polyspace uses this information to interpret syntax that is not part of the C/C++ Standard, but comes from language extensions.
For example, the option allows additional language keywords, such as
sfr, sbit, and bit. If you
do not specify your compiler, these additional keywords can cause compilation errors
during Polyspace analysis.
Polyspace does not actually invoke your compiler for compilation. In particular:
You cannot specify compiler flags directly in the Polyspace analysis. To emulate your compiler flags, trace your build command or manually specify equivalent Polyspace analysis options. See Specify Target Environment and Compiler Behavior.
Code Prover has a linking policy that is stricter than regular compilers. For instance, if your compiler allows declaration mismatches with specific compiler options, you cannot emulate this linking policy in Code Prover. See Troubleshoot Compilation and Linking Errors (Polyspace Code Prover).
Settings
Default: generic
Polyspace natively supports GCC, Clang, and Visual Studio® compilers. You can select any available target processor for these compilers.
For other supported specialty compilers, Polyspace supports specific target processors. See Target processor type (-target).
GCC Compilers
gnu3.4Analysis allows GCC 3.4 syntax.
gnu4.6Analysis allows GCC 4.6 syntax.
gnu4.7Analysis allows GCC 4.7 syntax.
For unsupported GCC extensions, see Limitations.
gnu4.8Analysis allows GCC 4.8 syntax.
For unsupported GCC extensions, see Limitations.
gnu4.9Analysis allows GCC 4.9 syntax.
For unsupported GCC extensions, see Limitations.
gnu5.xAnalysis allows GCC 5.x syntax. For a list of available GCC 5.x releases, see GCC releases.
If you select
gnu5.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
gnu6.xAnalysis allows GCC 6.x syntax. For a list of available GCC 6.x releases, see GCC releases.
If you select
gnu6.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
gnu7.xAnalysis allows GCC 7.x syntax. For a list of available GCC 7.x releases, see GCC releases.
If you select
gnu7.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
gnu8.xAnalysis allows GCC 8.x syntax. For a list of available GCC 8.x releases, see GCC releases.
If you select
gnu8.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options..For unsupported GCC extensions, see Limitations.
gnu9.xAnalysis allows GCC 9.x syntax. For a list of available GCC 9.x releases, see GCC releases.
If you select
gnu9.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
gnu10.xAnalysis allows GCC 10.x syntax. For a list of available GCC 10.x releases, see GCC releases.
If you select
gnu10.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
gnu11.xAnalysis allows GCC 11.x syntax. For a list of available GCC 11.x releases, see GCC releases.
If you select
gnu11.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
gnu12.xAnalysis allows GCC 12.x syntax. For a list of available GCC 12.x releases, see GCC releases.
If you select
gnu12.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
gnu13.xAnalysis allows GCC 13.x syntax. For a list of available GCC 13.x releases, see GCC releases.
If you select
gnu13.x, you can specify only a subset of GCC-based compiler targets by using the optionTarget processor type (-target). To specify other targets that are not part of this subset, use the optionGeneric target options.For unsupported GCC extensions, see Limitations.
Clang Compilers
clang3.xAnalysis allows Clang syntax for these versions:
3.5.0, 3.5.1, and 3.5.2
3.6.0, 3.6.1, and 3.6.2
3.7.0 and 3.7.1
3.8.0 and 3.8.1
3.9.0 and 3.9.1
clang4.xAnalysis allows Clang 4.0.0, and 4.0.1 syntax.
clang5.xAnalysis allows Clang 5.0.0, 5.0.1, and 5.0.2 syntax.
clang6.xAnalysis allows Clang 6.0.0 and 6.0.1 syntax.
clang7.xAnalysis allows Clang 7.0.0, 7.0.1, and 7.1.0 syntax.
clang8.xAnalysis allows Clang 8.0.0 and 8.0.1 syntax.
clang9.xAnalysis allows Clang 9.0.0 and 9.0.1 syntax.
clang10.xAnalysis allows Clang 10.0.0 and 10.0.1 syntax.
clang11.xAnalysis allows Clang 11.0.0, 11.0.1, and 11.1.0 syntax.
clang12.xAnalysis allows Clang 12.0.0 and 12.0.1 syntax.
clang13.xAnalysis allows Clang 13.0.0 and 13.0.1 syntax.
clang14.xAnalysis allows Clang 14 syntax.
clang15.xAnalysis allows Clang 15 syntax.
clang16.xAnalysis allows Clang 16 syntax.
Visual Studio Compilers
visual9.0Analysis allows Microsoft® Visual C++® 2008 syntax.
visual10.0Analysis allows Microsoft Visual C++ 2010 syntax.
visual11.0Analysis allows Microsoft Visual C++ 2012 syntax.
visual12.0Analysis allows Microsoft Visual C++ 2013 syntax.
visual14.0Analysis allows Microsoft Visual C++ 2015 syntax (supports Microsoft Visual Studio update 2).
visual15.xAnalysis allows Microsoft Visual C++ 2017 syntax. For a list of available Microsoft Visual Studio 2017 versions, see Visual Studio 2017 Release Notes History.
visual16.xAnalysis allows Microsoft Visual C++ 2019 syntax. For a list of available Microsoft Visual Studio 2019 versions, see Visual Studio 2019 Release Notes History.
visual17.xAnalysis allows Microsoft Visual C++ 2022 syntax. For a list of available Microsoft Visual Studio 2022 versions, see Visual Studio 2022 Release Notes History.
Other Compilers
armccAnalysis allows non-ANSI® C syntax and semantics associated with the ARM® v5 compiler.
If you select
armcc, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the ARM v5 compiler.armclangAnalysis allows non-ANSI C syntax and semantics associated with the ARM v6 compiler.
If you select
armclang, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the ARM v6 compiler.codewarriorAnalysis allows non-ANSI C syntax and semantics associated with the NXP CodeWarrior® compiler.
If you select
codewarrior, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the NXP CodeWarrior compiler.cosmicAnalysis allows non-ANSI C syntax and semantics associated with the Cosmic compiler.
If you select
cosmic, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the Comic compiler.diabAnalysis allows non-ANSI C syntax and semantics associated with the Wind River® Diab compiler.
If you select
diab, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the Wind River Diab compiler.Note
If you use the Diab compiler version
7.x, specify-compilerasclang15.x.genericAnalysis allows only standard syntax.
The language standard is determined by your choice for the following options:
If you do not specify a standard explicitly, the standard depends on your choice of compiler.
greenhillsAnalysis allows non-ANSI C syntax and semantics associated with a Green Hills® compiler.
If you select
greenhills, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for a Green Hills compiler.iarAnalysis allows non-ANSI C syntax and semantics associated with the compilers from IAR Systems (www.iar.com).
iar-ewAnalysis allows non-ANSI C syntax and semantics associated with the IAR Embedded Workbench compiler.
If you select
iar-ew, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the IAR Embedded Workbench compiler.intelAnalysis allows non-ANSI C syntax and semantics associated with the Intel® C++ Compiler Classic (icc/icl) compiler.
If you select
intel, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the Intel C++ Compiler Classic (icc/icl) compiler.keilAnalysis allows non-ANSI C syntax and semantics associated with the Keil™ products from ARM (www.keil.com).
microchipAnalysis allows non-ANSI C syntax and semantics associated with the MPLAB XC8 C compiler.
If you select
microchip, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the MPLAB XC8 C compiler.renesasAnalysis allows non-ANSI C syntax and semantics associated with the Renesas® compiler.
If you select
renesas, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the Renesas compiler.taskingAnalysis allows non-ANSI C syntax and semantics associated with the TASKING compiler.
If you select
tasking,in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the TASKING compiler.tiAnalysis allows non-ANSI C syntax and semantics associated with the Texas Instruments® compiler.
If you select
ti, in the user interface of the Polyspace desktop products, the optionTarget processor type (-target)shows only the targets that are allowed for the Texas Instruments compiler.
Tips
Your compiler specification determines the values of many compiler-specific macros. In case you want to know how Polyspace defines a specific macro, use the option
-dump-preprocessing-info.To override the macro definition, use the option
Preprocessor definitions (-D).To undefine a macro, use the option
Disabled preprocessor definitions (-U).
If you use a Visual Studio compiler, you must use a
Target processor type (-target)option that setslong longto 64 bits. Compatible targets include:i386,sparc,m68k,powerpc,tms320c3x,sharc21x61,mpc5xx,x86_64, ormcpuwithlong longset to 64 (-long-long-is-64bitsat the command line).If you use the option
Check JSF AV C++ rules (-jsf-coding-rules), select the compilergeneric. If you use another compiler, Polyspace cannot check the JSF® coding rules that require conforming to the ISO standard. For example, AV Rule 8: “All code shall conform to ISO/IEC 14882:2002(E) standard C++.”Polyspace supports these keywords, pragmas, and attributes to define weak symbols:
Keywords
__weak__weak__Pragmas
#pragma weak symbol#pragma WEAK symbol#pragma WEAK(symbol)#pragma weak "symbol#pragma weak symbol=defaultGNU Attributes
__attribute__((weak))__attribute__ ((weak, alias("default")))
When analyzing code generated from a Simulink® model that specifies Device vendor (Simulink) as
Texas Instruments, Polyspace sets the-compileroption togeneric.
Limitations
GNU Compilers
Polyspace does not support certain features of GNU compilers:
GNU® compilers versions 4.7 and later:
Nested functions.
For instance, the function
baris nested in functionfoo:int foo (int a, int b) { int bar (int c) { return c * c; } return bar (a) + bar (b); }Binary operations with vector types where one operand uses the shorthand notation for uniform vectors.
For instance, in the addition operation,
2+a, 2 is used as a shorthand notation for {2,2,2,2}.typedef int v4si __attribute__ ((vector_size (16))); v4si res, a = {1,2,3,4}; res = 2 + a; /* means {2,2,2,2} + a */Forward declaration of function parameters.
For instance, the parameter
lenis forward declared:void func (int len; char data[len][len], int len) { /* … */ }Complex integer data types.
However, complex floating point data types are supported.
Initialization of structures with flexible array members using an initialization list.
For instance, the structure
Shas a flexible array membertab. A variable of typeSis directly initialized with an initialization list.You see a warning during analysis and a red check in the results when you dereference, for instance,struct S { int x; int tab[]; /* flexible array member - not supported */ }; struct S s = { 0, 1, 2} ;s.tab[1].128-bit variables.
Polyspace cannot analyze this data type semantically. Bug Finder allows use of 128-bit data types, but Code Prover shows a compilation error if you use such a data type, for instance, the GCC extension
__float128.
GNU compilers version 7.x:
Type names
_FloatNand_FloatNxare not semantically supported. The analysis treats them as typefloat,double, orlong double.Constants of type
_FloatNor_FloatNxwith suffixesfN,FN, orfNx, such as1.2f123or2.3F64xare not supported.
Visual Studio Compilers
Polyspace does not support certain features of Visual Studio compilers:
C++ Accelerated Massive Parallelism (AMP).
C++ AMP is a Visual Studio feature that accelerates your C++ code execution for certain types of data-parallel hardware on specific targets. You typically use the
restrictkeyword to enable this feature.void Buffer() restrict(amp) { ... }__assumestatements.You typically use
__assumewith a condition that is false. The statement indicates that the optimizer must assume the condition to be henceforth true. Code Prover cannot reconcile this contradiction. You get the error:Asked for compulsory presence of absent entity : assert
Managed Extensions for C++ (required for the .NET Framework), or its successor, C++/CLI (C++ modified for Common Language Infrastructure)
__declspeckeyword with attributes other thannoreturn,nothrow,selectanyorthread.
Other Compilers
Polyspace does not support some constructs specific to TASKING or Cosmic compilers.
For instance, the following constructs are not supported at all. Using them can cause an error.
Half-precision floating point data type such as
_Float16Fractional fixed point data types such as
__sfract,__fract,__accum,__laccum
Polyspace does not support the Embarcadero C++ compiler.
Polyspace System Headers
If you do not specify the path to your compiler headers, Polyspace uses its own system headers and your project might not compile even if your code compiles with your compiler.
To make sure that Polyspace uses your compiler header files, run polyspace-configure or specify the paths to your
compiler header files manually. See Provide Standard Library Headers for Polyspace Analysis.
Command-Line Information
Parameter and Values
Parameter: -compiler |
Value (GCC): gnu3.4 | gnu4.6 | gnu4.7 |
gnu4.8 | gnu4.9 | gnu5.x | gnu6.x | gnu7.x | gnu8.x | gnu9.x | gnu10.x | gnu11.x |
gnu12.x |
Value (Clang): clang3.x | clang4.x |
clang5.x | clang6.x | clang7.x | clang8.x | clang9.x | clang10.x | clang11.x |
clang12.x | clang13.x |
Value (Visual Studio): visual9.0 | visual10.0 | visual11.0 | visual12.0
| visual14.0 | visual15.x | visual16.x | visual17.x |
Value (Other): armcc | armclang |
codewarrior | cosmic | diab | generic | greenhills | iar | iar-ew | intel | keil |
microchip | renesas | tasking | ti |
Default:
generic |
Examples
Example 1 (Bug Finder):
polyspace-bug-finder -lang c -sources
|
Example 2 (Bug Finder):
polyspace-bug-finder -lang cpp -sources
|
Example 1 (Code Prover):
polyspace-code-prover -lang c -sources
|
Example 2 (Code Prover):
polyspace-code-prover -lang cpp -sources
|
Example 1 (Bug Finder Server):
polyspace-bug-finder-server -lang c -sources
|
Example 2 (Bug Finder Server):
polyspace-bug-finder-server -lang cpp -sources
|
Example 1 (Code Prover Server):
polyspace-code-prover-server -lang c -sources
|
Example 2 (Code Prover Server):
polyspace-code-prover-server -lang cpp -sources
|