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 Added | Source Code Language |
|---|---|
Only files with extension .c | C |
Only files with extension .cpp or
.cc | CPP |
Files with extension .c,
.cpp, and .cc | C-CPP |
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. See Dependencies for ways in which the source code language can be automatically determined.
Polyspace Platform user interface (desktop products only): In your project configuration, on the Build tab, select the Target & Compiler node and then select a value for this option.
Command line and options file: Use the option
-lang. See Command-Line Information.
Settings
Default: Based on file extensions.
CIf 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.
CPPIf 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-CPPIf your project contains C and C++ source files, choose this setting. This value allows for C and C++ language conventions.
.cfiles 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-configurecommand orpolyspaceConfigurefunction, the value of this option is determined by the file extensions.For a project with both
.cand.cppfiles, the language optionC-CPPis 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
.cand.cppfiles, if you use the languageC-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-CPPversus languageC.C and C++ compilers have some differences in assumptions. For instance, the underlying type of
enumisintfor a C compiler. However, the underlying type ofenumis implementation-defined for a C++ compiler. When usingC-CPPas 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
|
Example (Code Prover):
polyspace-code-prover -lang cpp -sources
|
Example (Bug Finder Server):
polyspace-bug-finder-server -lang c-cpp -sources
|
Example (Code Prover
Server):
polyspace-code-prover-server -lang
cpp -sources |
Example (Bug Finder):
polyspace-bug-finder -lang c -sources
|
Example (Code Prover):
polyspace-code-prover -lang c -sources
|
Example (Bug Finder Server):
polyspace-bug-finder-server -lang c -sources
|
Example (Code Prover Server):
polyspace-code-prover-server -lang c -sources
|