Main Content

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

User interface (desktop products only): In your project configuration, the option is on the Target & Compiler node.

User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Build tab on the Target & Compiler node. This option is renamed as Compilation toolchain (Static Analysis) in Polyspace platform user interface. 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.

Settings

Default: generic

GCC Compilers

gnu3.4

Analysis allows GCC 3.4 syntax.

gnu4.6

Analysis allows GCC 4.6 syntax.

gnu4.7

Analysis allows GCC 4.7 syntax.

For unsupported GCC extensions, see Limitations.

gnu4.8

Analysis allows GCC 4.8 syntax.

For unsupported GCC extensions, see Limitations.

gnu4.9

Analysis allows GCC 4.9 syntax.

For unsupported GCC extensions, see Limitations.

gnu5.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options.

For unsupported GCC extensions, see Limitations.

gnu6.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options.

For unsupported GCC extensions, see Limitations.

gnu7.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options.

For unsupported GCC extensions, see Limitations.

gnu8.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options..

For unsupported GCC extensions, see Limitations.

gnu9.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options.

For unsupported GCC extensions, see Limitations.

gnu10.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options.

For unsupported GCC extensions, see Limitations.

gnu11.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options.

For unsupported GCC extensions, see Limitations.

gnu12.x

Analysis 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 option Target processor type (-target). To specify other targets that are not part of this subset, use the option Generic target options.

For unsupported GCC extensions, see Limitations.

Clang Compilers

clang3.x

Analysis 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.x

Analysis allows Clang 4.0.0, and 4.0.1 syntax.

clang5.x

Analysis allows Clang 5.0.0, 5.0.1, and 5.0.2 syntax.

clang6.x

Analysis allows Clang 6.0.0 and 6.0.1 syntax.

clang7.x

Analysis allows Clang 7.0.0, 7.0.1, and 7.1.0 syntax.

clang8.x

Analysis allows Clang 8.0.0 and 8.0.1 syntax.

clang9.x

Analysis allows Clang 9.0.0 and 9.0.1 syntax.

clang10.x

Analysis allows Clang 10.0.0 and 10.0.1 syntax.

clang11.x

Analysis allows Clang 11.0.0, 11.0.1, and 11.1.0 syntax.

clang12.x

Analysis allows Clang 12.0.0 and 12.0.1 syntax.

clang13.x

Analysis allows Clang 13.0.0 and 13.0.1 syntax.

Visual Studio Compilers

visual9.0

Analysis allows Microsoft® Visual C++® 2008 syntax.

visual10.0

Analysis allows Microsoft Visual C++ 2010 syntax.

visual11.0

Analysis allows Microsoft Visual C++ 2012 syntax.

visual12.0

Analysis allows Microsoft Visual C++ 2013 syntax.

visual14.0

Analysis allows Microsoft Visual C++ 2015 syntax (supports Microsoft Visual Studio® update 2).

visual15.x

Analysis allows Microsoft Visual C++ 2017 syntax. For a list of available Microsoft Visual Studio 2017 versions, see Visual Studio 2017 Release Notes History.

visual16.x

Analysis allows Microsoft Visual C++ 2019 syntax. For a list of available Microsoft Visual Studio 2019 versions, see Visual Studio 2019 Release Notes History.

visual17.x

Analysis 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

armcc

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the ARM v5 compiler.

See ARM v5 Compiler (-compiler armcc).

armclang

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the ARM v6 compiler.

See ARM v6 Compiler (-compiler armclang).

codewarrior

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the NXP CodeWarrior compiler.

See NXP CodeWarrior Compiler (-compiler codewarrior).

cosmic

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the Comic compiler.

See Cosmic Compiler (-compiler cosmic).

diab

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the Wind River Diab compiler.

See Diab Compiler (-compiler diab).

generic

Analysis 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.

greenhills

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for a Green Hills compiler.

See Green Hills Compiler (-compiler greenhills).

iar

Analysis allows non-ANSI C syntax and semantics associated with the compilers from IAR Systems (www.iar.com).

iar-ew

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the IAR Embedded Workbench compiler.

See IAR Embedded Workbench Compiler (-compiler iar-ew).

intel

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the Intel C++ Compiler Classic (icc/icl) compiler.

See Intel C++ Compiler Classic (icc/icl) (-compiler intel).

keil

Analysis allows non-ANSI C syntax and semantics associated with the Keil™ products from ARM (www.keil.com).

microchip

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the MPLAB XC8 C compiler.

See MPLAB XC8 C Compiler (-compiler microchip).

renesas

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the Renesas compiler.

See Renesas Compiler (-compiler renesas).

tasking

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the TASKING compiler.

See TASKING Compiler (-compiler tasking).

ti

Analysis 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 option Target processor type (-target) shows only the targets that are allowed for the Texas Instruments compiler.

See Texas Instruments Compiler (-compiler ti).

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.

  • If you use a Visual Studio compiler, you must use a Target processor type (-target) option that sets long long to 64 bits. Compatible targets include: i386, sparc, m68k, powerpc, tms320c3x, sharc21x61, mpc5xx, x86_64, or mcpu with long long set to 64 (-long-long-is-64bits at the command line).

  • If you use the option Check JSF AV C++ rules (-jsf-coding-rules), select the compiler generic. 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=default

    • GNU 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 -compiler option to generic.

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 bar is nested in function foo:

      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 len is 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 S has a flexible array member tab. A variable of type S is directly initialized with an initialization list.

      struct S {
          int x;
          int tab[];            /* flexible array member - not supported */
      };
      struct S s = { 0, 1, 2} ;
      You see a warning during analysis and a red check in the results when you dereference, for instance, 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 _FloatN and _FloatNx are not semantically supported. The analysis treats them as type float, double, or long double.

    • Constants of type _FloatN or _FloatNx with suffixes fN, FN, or fNx, such as 1.2f123 or 2.3F64x are 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 restrict keyword to enable this feature.

    void Buffer() restrict(amp) 
    {
      ... 
    }

  • __assume statements.

    You typically use __assume with 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)

  • __declspec keyword with attributes other than noreturn, nothrow, selectany or thread.

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 _Float16

    • Fractional 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 "file1.c,file2.c" -compiler gnu4.6
Example 2 (Bug Finder): polyspace-bug-finder -lang cpp -sources "file1.cpp,file2.cpp" -compiler visual9.0
Example 1 (Code Prover): polyspace-code-prover -lang c -sources "file1.c,file2.c" -lang c -compiler gnu4.6
Example 2 (Code Prover): polyspace-code-prover -lang cpp -sources "file1.cpp,file2.cpp" -compiler visual9.0
Example 1 (Bug Finder Server): polyspace-bug-finder-server -lang c -sources "file1.c,file2.c" -compiler gnu4.6
Example 2 (Bug Finder Server): polyspace-bug-finder-server -lang cpp -sources "file1.cpp,file2.cpp" -compiler visual9.0
Example 1 (Code Prover Server): polyspace-code-prover-server -lang c -sources "file1.c,file2.c" -lang c -compiler gnu4.6
Example 2 (Code Prover Server): polyspace-code-prover-server -lang cpp -sources "file1.cpp,file2.cpp" -compiler visual9.0