-size-t-type-is
Specify the underlying data type of size_t
Description
Specify the underlying data type of size_t explicitly: unsigned char, unsigned short, unsigned int, unsigned long or unsigned long long. If you do not specify this option, your choice of compiler determines the underlying type.
Set Option
Set the option using one of these methods:
Polyspace Platform user interface (desktop products only): This option is not directly available in the Polyspace Platform user interface. In your project configuration, on the Build tab, select Target & Compiler and then configure the settings for the option Processor. Select a value for the option Type of size_t in the Edit Processor dialog box. For more information, see
Processor.Command line and options file: Use the option
-size-t-type-is. See Command-Line Information.
Why Use This Option
The analysis associates a data type with size_t when you specify your compiler using the option Compilation toolchain (Static analysis). In most cases, you do not have to explicitly use this option and specify an underlying type for size_t.
In some situations, when building your code, you might be using a compiler option that changed the compiler's default definition of size_t. In these cases, emulate your compiler option by using this Polyspace® analysis option. Otherwise, you might see an error message related to size_t during Polyspace analysis. If you see such an error message, to probe further and determine the underlying type of size_t, compile this code with your compiler using the options that you typically use:
/* Header defines malloc as void* malloc (size_t size) #include <stlib.h> void* malloc (unsigned int size);
size_t using a type different from unsigned int. Replace unsigned int with another type such as unsigned long and try again till you determine the underlying type of size_t.Settings
Default:
defined-by-compiler
defined-by-compilerYour specification for
Compilation toolchain (Static analysis)determines the underlying type ofsize_t.unsigned-intThe analysis considers
unsigned intas the underlying type ofsize_t.unsigned-longThe analysis considers
unsigned longas the underlying type ofsize_t.unsigned-long-longThe analysis considers
unsigned long longas the underlying type ofsize_t.unsigned-charThe analysis considers
unsigned charas the underlying type ofsize_t.unsigned-shortThe analysis considers
unsigned shortas the underlying type ofsize_t.
Tips
Compilation errors from incorrect definition of size_t can appear in unexpected ways. For instance, you might see an error like this:
first parameter of allocation function must be of type "size_t"
void * operator new(size_t size);
size_t
definition from your Polyspace analysis configuration, but your declaration might be using a different size_t definition from a compiler header. The mismatch in the size_t definitions leads to a mismatch in the declarations of the allocation functions and shows up as an error message about the allocation functions.Command-Line Information
Parameter: -size-t-type-is |
Value:
defined-by-compiler | unsigned-char | unsigned-int | unsigned-short | unsigned-long | unsigned-long-long |
Default:
defined-by-compiler |
Example (Bug Finder):
polyspace-bug-finder -size-t-type-is unsigned-long |
Example (Code Prover):
polyspace-code-prover -size-t-type-is unsigned-long |
Example (Bug Finder Server):
polyspace-bug-finder-server -size-t-type-is unsigned-long |
Example (Code Prover Server):
polyspace-code-prover-server -size-t-type-is unsigned-long |