3 ms·
We can convert that unsigned 32-bit number in to a 64-bit number: #include <stdint.h> int64_t completion = (int64_t)time(NULL) + 30; do {
by strenholme 5y ago
We can convert that unsigned 32-bit number in to a 64-bit number:
#include <stdint.h>
int64_t completion = (int64_t)time(NULL) + 30;
do {
int64_t remaining = completion - (int64_t)time(NULL);
/* ... */
} while (remaining > 0);
There’s some slowdown doing 64-bit int math on a 32-bit system, but the above works.
- mlyle 5y agoYes. We're talking about growing time_t from int32_t to int64_t, instead of uint32_t. If you change it to uint32_t behind the scenes, some code will silently fail while compiling OK, because it was not expecting unsigned math.