[cs631apue] stat timespec vs time_t
Jan Schaumann
jschauma at stevens.edu
Wed Nov 23 22:52:39 EST 2011
afonsec1 <afonsec1 at stevens.edu> wrote:
> I'm having compiling issues using struct stat.
>
> I include
>
> #include <sys/types.h>
> #include <sys/stat.h>
>
> but for some reasons,
>
> the field struct stat.st_mtime of type time_t could not be resolved.
> Rather, st_mtim of type timespec is defined.
I'm afraid you'd have to post more details about the code in question.
For example, the following code will work just fine:
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main(int argc, char **argv) {
struct stat sb;
if (stat(argv[0], &sb) != 0) {
err(EXIT_FAILURE, "Unable to stat %s:", argv[0]);
}
printf("%ld\n", sb.st_mtime);
return 0;
}
-Jan
More information about the cs631apue
mailing list