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
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 orpolyspaceConfigure
function, the value of this option is determined by the file extensions.For a project with both
.c
and.cpp
files, the language optionC-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 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-CPP
versus languageC
.C and C++ compilers have some differences in assumptions. For instance, the underlying type of
enum
isint
for a C compiler. However, the underlying type ofenum
is implementation-defined for a C++ compiler. When usingC-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
|
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
|