HI,
I have a bit of problem in compiling my c program. When I compile my program i get the following error.
Code:
ldirfunc.c:13: error: conflicting types for opendir
/usr/include/dirent.h:135: error: previous declaration of opendir was here
Program snippet:
Code:
#include "Dirent.h"
#include<sys/stat.h>
#include<string.h>
#include<sys/types.h>
#include "syscall.h"
#include<fcntl.h>
#include<sys/dir.h>
#include<malloc.h>
Dir *opendir(char *dirname){
int fd;
struct stat stbuf;
Dir *dp;
if((fd=open(dirname,O_RDONLY,0)) == -1 || fstat(fd,&stbuf) == -1 ||
((stbuf.st_mode * S_IFMT) != S_IFDIR) ||
(dp = (Dir *) malloc (sizeof(Dir))) != NULL)
return NULL;
dp->fd=fd;
return dp;
}
What I understand from the error, that my opendir function is already declared in the dirent.h(not the one i use, Dirent.h). dirent.h must have been included somewhere, may in some of the header files that i use.
Do we have any option while compiling to neglect these redefinition errors? I want to use my opendir function and not the predefined one.
I am a beginner in c programming, so please excuse me for my mistakes.
thanks to all!