Management of size_t (-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
User interface (desktop products only): In your project configuration, the option is on the Target & Compiler node.
User interface
(Polyspace Platform, desktop products only):
In your project configuration, the option is in the Edit Processor window. This
window can be opened from the Target & Compiler node in the
Build tab. See Processor Details
.
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 Compiler
(-compiler)
. 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-compiler
Your specification for
Compiler (-compiler)
determines the underlying type ofsize_t
.unsigned-int
The analysis considers
unsigned int
as the underlying type ofsize_t
.unsigned-long
The analysis considers
unsigned long
as the underlying type ofsize_t
.unsigned-long-long
The analysis considers
unsigned long long
as the underlying type ofsize_t
.unsigned-char
The analysis considers
unsigned char
as the underlying type ofsize_t
.unsigned-short
The analysis considers
unsigned short
as 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 |