I want to get the last modified date of a file in C. Almost all sources I found use something along this snippet:
char *get_last_modified(char *file) {
struct tm *clock;
struct stat attr;
stat(file, &attr);
clock = gmtime(&(attr.st_mtime));
return asctime(clock);
}
But the attr
doesn't even have a field st_mtime
, only st_mtimespec
. Yet, when using this my Eclipse tells me that passing argument 1 of 'gmtime' from incompatible pointer type
on the line clock = gmtime(&(attr.st_mtimespec));
What am I doing wrong?
PS: I'm developing on OSX Snow Leopard, Eclipse CDT and using GCC as Cross-Platform compiler