Is nSysTime a long or unsigned long?

I’ve created a variable

unsigned long lastIncorrectTime

. Whenever I compare it to


I get a warning:

Comparison between 'signed' and 'unsigned' operands.

. I thought


is a unsigned long when using a Vex Cortex?




intrinsic const unsigned long propertyIndex(nSysTime, propertySystem, kSystemSysTime);

Changing my


to a normal long removes the warning. I’ll also note that JPearman uses

long nSysTimeOffset;

in his gyroLib2.c.

I would treat nSysTime as long, that’s what we do internally to the ROBOTC VM. ROBOTC supports many different platforms and has evolved a lot over the years. Subsequently there are some mistakes in the definition of some of these very old features. Inside the VM nSysTime is what we call a TLargeValue, this changes depending on what the platform is, on the cortex it is a 32 bit number, on some old 8 bit platforms it would have been a 16 bit number. Here is the actual definition for the cortex from the VM code.

typedef signed   long TLargeValue;		// 32-bits

Although the intrinsic definition you found says it should be unsigned long, the compiler will often cast these to signed long when assigning to a variable, for example, theses line of code.

unsigned long tmp;
tmp = nSysTime;

become this when turned into assembly language by ROBOTC.

0003: 4E292C000010tmp:S00(ulong) = (long) GetProperty(propertySystem, 16)

notice the (rather silly) conversion to first long and then unsigned long by the compiler.

So that’s more than you needed (or probably wanted) to know, bottom line, use it as a long and all will be ok. Maximum duration will be 2147483647 mS (0x7FFFFFFF) or about 24.8 days, plenty long enough for a match :slight_smile: