Why is this giving an error error: member reference base type '__darwin_time_t' (aka 'long') is not a structure or union
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>

int main(){



struct stat sd;
//struct timespec td;

char *path=malloc(9);
strncpy(path, "file.txt",8);
path[8]='\0';
stat(path, &sd);
//td.tv_sec=sd.st_mtime;
printf("%lu.%lu\n",sd.st_mtime, sd.st_mtime.tv_nsec);
return 0;
}