long t; ... if (stat(filename, &statbuf)) { perror(filename); exit(1); } t = (long)statbuf.st_mtime; ...
Solution:
That cast is bad and should be omitted. The code functions fine without it — an assignment is a conversion to the type of the variable. (So is a return from a function a conversion to the declared return type of the function.)
Why it's bad is illustrated by mistakes with, for example, levels of indirection:
t = (long)&statbuf.st_mtime;
This assigns t to be an integer representation of the address of the st_mtime member of statbuf, which is surely not what's intended. With the cast, though, it will execute and perform this incorrect task. Without the cast, it will give a fatal error message.
Errors are bad, but error messages are good (because they allow you to fix the errors, and errors are bad). Casts suppress error messages, so that is bad. Casts are only needed very very occasionally in C. Only use a cast if necessary. If you're not sure, leave it out (and you will almost certainly find that it's not necessary).