Here are the c files that I'm trying to compile. Please note that I haven't cleaned up the code yet.
Code:[cdalten@localhost YAPP]$ more diren.h #define MAX 14 typedef struct { long ino; char name[MAX + 1]; } Dirent; typedef struct { int fd; Dirent d; } DIR;Code:[cdalten@localhost YAPP]$ more opendir.c #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include "diren.h" #define PATH "/home/cdalten/oakland" DIR *opendirectory(void) { int fd; DIR *dp; if ( (fd = open(PATH, O_RDONLY)) < 0) { perror(PATH); exit(EXIT_FAILURE); } dp = (DIR *)malloc(sizeof(DIR)); dp->fd = fd; return dp; } int main(void) { size_t n; char buf[BUFSIZ]; DIR *dfp; dfp = opendirectory(); /*if ( (fd = open(PATH, O_RDONLY)) < 0) { perror(PATH); exit(EXIT_FAILURE); } while ((n = read(fd, buf, BUFSIZ)) > 0) { if (write(1, buf, n) != n) { fprintf(stderr, "Can't call write\n"); exit(EXIT_FAILURE); } } close(fd);*/ exit(EXIT_SUCCESS); } [cdalten@localhost YAPP]$And here is the error that I get.....Code:[cdalten@localhost YAPP]$ more readdir.c #include <sys/dir.h> #include "diren.h" DIR *readdirectory() { struct direct dirbuf; static Dirent d; } [cdalten@localhost YAPP]$
What am I doing wrong here?[cdalten@localhost YAPP]$ gcc -g opendir.c readdir.c -o readit
In file included from readdir.c:2:
diren.h:11: error: conflicting types for ‘DIR’
/usr/include/dirent.h:128: error: previous declaration of ‘DIR’ was here
[cdalten@localhost YAPP]$



LinkBack URL
About LinkBacks


