Main Content

Source code language (-lang)

Specify language of source files

Description

Specify the language of your source files. Before specifying other configuration options, choose this option because other options change depending on your language selection. This option applies to both dynamic testing and static analysis.

If you add files during project setup, the language selection can change from the default.

Files AddedSource Code Language
Only files with extension .cC
Only files with extension .cpp or .ccCPP
Files with extension .c, .cpp, and .ccC-CPP

Set Option

User interface (desktop products only): In your project configuration, the option is on the Target & Compiler node. See Dependencies for ways in which the source code language can be automatically determined.

User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Target & Compiler node of the Build tab. See Dependencies for ways in which the source code language can be automatically determined.

Command line and options file: Use the option -lang. See Command-Line Information.

Settings

Default: Based on file extensions.

C

If your project contains only C files, choose this setting. This value restricts the verification to C language conventions. All files are interpreted as C files, regardless of their file extension.

CPP

If your project contains only C++ files, choose this setting. This value restricts the verification to C++ language conventions. All files are interpreted as C++ files, regardless of their file extension.

C-CPP

If your project contains C and C++ source files, choose this setting. This value allows for C and C++ language conventions. .c files are interpreted as C files. Other file extensions are interpreted as C++ files.

Dependencies

  • The language option allows and disallows many options and option values. Some options change depending on your language selection. For more information, see the individual analysis option pages.

  • If you create a Polyspace® project or options file from your build system using the polyspace-configure command or polyspaceConfigure function, the value of this option is determined by the file extensions.

    For a project with both .c and .cpp files, the language option C-CPP is used. During the analysis, each file is compiled based on the language standard determined by the file extensions. After the compilation, Polyspace verifies such mixed projects as C++ projects.

Tips

  • For a project with both .c and .cpp files, if you use the language C-CPP, each file is compiled based on the language standard determined by the file extensions. After the compilation, Polyspace verifies such mixed projects as C++ projects.

    In particular, the analysis links all files as C++ files. Because of differences in linking behavior between C and C++, you might see differences in linking errors or warnings when C files in the mixed C-C++ projects are compiled with language C-CPP versus language C.

  • C and C++ compilers have some differences in assumptions. For instance, the underlying type of enum is int for a C compiler. However, the underlying type of enum is implementation-defined for a C++ compiler. When using C-CPP as the language, the difference assumptions of C and C++ compiler can lead to a failed analysis.

Command-Line Information

Parameter: -lang
Value: c | cpp| c-cpp
Default: Based on file extensions
Example (Bug Finder): polyspace-bug-finder -lang c-cpp -sources "file1.c,file2.cpp"
Example (Code Prover): polyspace-code-prover -lang cpp -sources "file1.cpp,file2.cpp"
Example (Bug Finder Server): polyspace-bug-finder-server -lang c-cpp -sources "file1.c,file2.cpp"
Example (Code Prover Server): polyspace-code-prover-server -lang cpp -sources "file1.cpp,file2.cpp"
Example (Bug Finder): polyspace-bug-finder -lang c -sources "file1.c,file2.c"
Example (Code Prover): polyspace-code-prover -lang c -sources "file1.c,file2.c"
Example (Bug Finder Server): polyspace-bug-finder-server -lang c -sources "file1.c,file2.c"
Example (Code Prover Server): polyspace-code-prover-server -lang c -sources "file1.c,file2.c"