A type not comparable with itself?

Running this script:

time_t t;
int tb = (t == t);

produces this message:

*ERROR Line 2: Types not compatible in comparison.

I find this surprising. How can a variable of some type not be compatible for comparison with another variable of the same type, particularly when the underlying type is an int-like type? :thinking:

The obvious workaround is to cast both occurrences of t in line 2 to, say, int32.

Another workaround is to write one’s own function to do such a comparison:

int CompareTimeT( time_t tX, time_t tY)
{
    return ( (int) tX - (int) tY );
}

A minor suggested enhancement: Add a library function such as int CompareTimeT( time_t, time_t);

This would allow the user to completely avoid the use of cast for such comparison, thereby tidying up his code.

I’m running 010 Editor v16.0.4 (ARM 64-bit) on macOS 26.5.2 (25F84).

010 Editor has a number of different dates types including time_t, time64_t, DOSDATE, DOSTIME, FILETIME, and OLETIME. Currently comparisons like <, >, and == are not supported with these types although we should add that in. Right now you have to cast to their equivalent numeric type to do a comparison. We’ll try to post here once we get native support added.

Graeme
SweetScape Software