Forced includes (-include)
R2026bSpecify files to be #include-d by every source file.
Since R2023b
Description
Specify files to be #include-d by every source file. These #include-s are added before preprocessing but the original sources are not modified. Use these files to define types, etc. that are not defined in the source code. This option is equivalent to the option Include (-include) (Polyspace Bug Finder).
Set Option
Set the option using one of these methods:
Polyspace Platform user interface (desktop products only): In your project configuration, on the Build tab, select the Target and Compiler node and then enter include file names for this option.
Command line: Use the option
-include. See Command-Line Information.
Why Use This Option
There can be many reasons why you want to #include a file in all your source files.
For instance, you can collect in one header file all workarounds for compilation errors. Use this option to provide the header file for analysis. Suppose you have compilation issues because Polyspace® does not recognize certain compiler-specific keywords. To work around the issues, #define the keywords in a header file and provide the header file with this option.
Settings
No Default
Specify the path to an include file. This file is #include-d in every source file involved in project build or static analysis. You can enter the full path to a file (recommended) or a relative path including just the file name.
If you enter the full path to a file, the analysis uses this path. You can enter a full path relative to a Polyspace Platform project path by using the project variable
$(PROJECTDIR). For more information, seeProject variables.If you enter a file name or the relative path to a file, the project build or static analysis attempts to resolve the paths with respect to the include paths specified in the project (in addition to default paths used by the compiler). For more information, see:
Command-Line Information
Parameter: -include |
| Default: None |
Value:
file (Use -include multiple times for multiple files) |
Example (Bug Finder):
polyspace-bug-finder -include `pwd`/sources/a_file.h -include /inc/inc_file.h |
Example (Code Prover):
polyspace-code-prover -include `pwd`/sources/a_file.h -include /inc/inc_file.h |
Example (Bug Finder Server):
polyspace-bug-finder-server -include `pwd`/sources/a_file.h -include /inc/inc_file.h |
Example (Code Prover Server):
polyspace-code-prover-server -include `pwd`/sources/a_file.h -include /inc/inc_file.h |
Tips
The forced includes specified for this option (also known as pre-includes) are provided to the equivalent compiler option during project build. If the compiler in your toolchain does not support forced includes, the option is ignored with a warning.
For instance, a GCC-based compiler supports forced includes using the option -include and a TI-based toolchain uses the option --preinclude=, while the Microchip XC8 compiler does not support the notion of forced includes at all.
Version History
Introduced in R2023b