怎么解决这一个warning
刚学Unix编程,系统是freebsd5.4, 编译器是gcc V3.4.2,在编译下面程序时总是有warning: assignment makes pointer from integer without a cast
google和baidu了大半天都没能找到,请高手指点下,怎样才能去掉warning?
出warning的地方加上中文释了
#define _POSIX_SOURCE 199506L /*有人说加上这一句可以去掉warning ,但我加上了也没用*/
#include "apue.h "
#include <dirent.h>
#include <errno.h> /*for definition of errno*/
#include <stdarg.h> /*for c variable arguments*/
#include <syslog.h>
int log_to_stderr;
int main(int argc, char *argv[])
{
DIR *dp;
struct dirent *dirp;
if(argc != 2)
err_quit( "usage: ls directory_name ");
if(dp = opendir(argv[1]) == NULL) /*出了warning*/
err_sys( "can 't open %s ", argv[1]);
while(dirp = readdir(dp) != NULL) /*出了warning*/
printf( "%s\n ", dirp -> d_name);
closedir(dp);
exit(0);
}
//#include "apue.h "
static void err_doit(int, int, const char *, va_list);
/*
* Nonfatal error related to a system call.
* Print a message and return.
*/
void err_ret(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, errno, fmt, ap);
va_end(ap);
}
/*
* Fatal error related to a system call
* Print a message and terminate
*/
void err_sys(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, errno, fmt, ap);
va_end(ap);
exit(1);
}
/*
* Fatal error unrelated to a system call
* Error code passed as explicit parameter.
* Print error message and terminate.
*/
void err_exit(int error, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, error, fmt, ap);
va_end(ap);
exit(1);
}
/*
* Fatal error related to a system call.
* Print &nbs