Enable portable word sizes
Allow compilation of code on host computer while retaining word sizes of target processor on which code is intended to run
Since R2023b
Description
Enable compilation of code on host computer while retaining word sizes of target processor on which the code is intended to run. This option allows you to emulate target processors with different word sizes on your host computer.
Set Option
In your Polyspace Platform project configuration, on the Build tab, select this option on the Target & Compiler node.
Why Use This Option
Use this option to emulate a target processor while running tests on your host computer. When you enable this option, Polyspace®
Test™ replaces the data types in the compiled code so that the word sizes in the compiled code remain the same as the word size of your processor. You specify the processor using the option Processor.
Say you have a 16-bit processor where the size of int is 16-bit. To emulate this processor in your host computer, select a 16-bit processor as the Processor and enable this option. Polyspace
Test replaces int in your code by a type that is 16-bit in length in your host computer, such as short. Consider this code:
unsigned int foo(void) {
unsigned int x = 65535;
x++;
if(x == 0)
return 16; // will be executed if sizeof(int)==16 bit
else
return 64; // will be executed sizeof(int)==64 bit
}foo() returns 16. When you enable portable word size, Polyspace
Test replaces int by short and foo() returns 16 even when you run the code in the host computer.unsigned short foo(void) {
unsigned short x = 65535;
x++;
if(x == 0)
return 16; // will be executed if sizeof(short)==16 bit
else
return 64; // will be executed sizeof(short)==64 bit
}Settings
OnEven if you build your Polyspace Platform project on your host computer, the build uses sizes of data types on the target processor.
Off (default)If you build your Polyspace Platform project on a host computer, the build uses sizes of data types on the host computer.
Command-Line Information
Parameter: -enable-portable-word-sizes |
Example: polyspace-test -build -project projectName.psprjx -enable-portable-word-sizes |
Tips
If the sizes of the data types in the target processor is the same as the sizes in the host computer, this option has no impact.
If your processor has data types that cannot be emulated in the host by type replacement, then this option is ignored. For instance, if your custom processor has a 24-bit
int, it is not possible to emulate this word size in the host because there is no data type in the host computer that has a 24-bit size.Using this option does not affect the values of named constants defined in
limits.h, such asCHAR_MINandCHAR_MAX.If the target processor you need is not listed in the Manage Processors window, create a custom processor. See
Custom Processor Details.
Version History
Introduced in R2023b