Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Yes. 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: