11-21-06 12:24 PM
Hello,
> I have a simple directory reading function
>
> DIR *dir;
> struct dirent *dirp;
>
>
> dir = opendir( /* some valid path */ );
> while ( (dirp = readdir( dir )) != NULL )
> printf( "%s\n", dirp->d_name );
>
>
> When I compile it in linux 2.4 with gcc 3.2 I get following error
>
> for line conatining the statement
> dir = opendir( /* some valid path */ );
> the gcc says "warning: assignment from incompatible pointer type"
>
> and for line
> printf( "%s\n", dirp->d_name );
> it says " dereferencing pointer to imcomplete type"
>
> i tried with including dirent.h as well as sys/dir.h but no lick
>
> it is such a simple thing and atill not working ,
> any help will be appreciated
Do you include the two following headers?
#include <sys/types.h>
#include <dirent.h>
You can find out the header(s) to include on your system for a
particular API using the man pages:
$ man opendir
Or, alternatively, for portable programs, you can read the Single Unix
Specification:
http://www.unix.org/version3/online.html
Cheers,
Loic.
[ Post a follow-up to this message ]
|