1) Should I assign this to a long?
2) What should I use when I want to send only 16 bits (there’s no data type in the SiMessagePort constructor that is 16 bit)?
3) What happens if I try to assign a data_int (32 bit) to an int (16 bit)?
SiMessagePort payload->data_int: Wiki says 32bit data type but my Leonardo thinks an int should be 16bit.
Re: SiMessagePort payload->data_int: Wiki says 32bit data type but my Leonardo thinks an int should be 16bit.
Hi,
It is of type int32_t, so it is always 32 bits on all platforms.
Long is not a fixed type and can have a different size on different platforms. On Arduino a long is same as int32_t.
Changing from int16_t to int32_t is okay since a int32_t can store all numbers an int16_t can.
The other way around is also possible (with a cast or warning without), but note that you might loose data when your value doesn't fit in a int16_t.
Corjan
It is of type int32_t, so it is always 32 bits on all platforms.
Long is not a fixed type and can have a different size on different platforms. On Arduino a long is same as int32_t.
Changing from int16_t to int32_t is okay since a int32_t can store all numbers an int16_t can.
The other way around is also possible (with a cast or warning without), but note that you might loose data when your value doesn't fit in a int16_t.
Corjan