The yarp::os::Stamp class uses int to represent the counter.
Since int has a different representation depending on the system, it should be using a fixed size type, for example int32_t.
Also it should probably use an unsigned type, i.e. uint32_t
cc @Nicogene @traversaro
@drdanz there are conditions where a negative counter (specifically -1) is employed to mean "invalid" or "not-available".
Ok for int32_t 馃憤馃徎
@drdanz there are conditions where a negative counter (specifically -1) is employed to mean "invalid" or "not-available".
Exactly, if the Stamp is not defined it has -1 has seq number and 0.0 has ts, changing it would be a break of ABI
Ok for int32_t
Technically, if only -1 is used, it could be possible to use uint32_t and define
getMaxCount() == std::numeric_limits<uint32_t>::max() - 1;
since -1 has the exact representation as std::numeric_limits<uint32_t>
(btw getMaxCount should be constexpr)
since -1 has the exact representation as std::numeric_limits
Yeah, but then how this relates to checks like this below:
If sequenceNumber is unsigned (likely it'll be changed to unsigned), then we need to change the check.
I'm afraid that similar checks might be spread around.
Most helpful comment
Exactly, if the Stamp is not defined it has -1 has seq number and 0.0 has ts, changing it would be a break of ABI
Ok for int32_t