当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 3 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 在《unix环境高级编程》中的ls核心程序编译出现错误
帖子发表于 : 2012-06-15 15:34 

注册: 2012-04-06 15:55
帖子: 125
送出感谢: 2
接收感谢: 0 次
没编过程序,在有段程序用gcc编译后,出现如下错误,为何
代码:
#include "apue.h"
#include<dirent.h>

int main(int argc, char *argv[])
   {
      DIR   *dp;
      struct dirent *dirp;
      if(argc !=2)
         err_quit("usage: ls directory_name");
      if((dp=openddir(argv[1]))==NULL)
         err_sys("can't open %s, argv[1]");
      while ((dirp=readdir(dp))!=NULL)
         printf("%s\n",dirp->d_name);
      colsedir(dp);
      exit(0);   
   }

出现如下错误
ls_test.c:1:18: error: apue.h: No such file or directory
ls_test.c: In function ‘main’:
ls_test.c:10: warning: assignment makes pointer from integer without a cast
ls_test.c:10: error: ‘NULL’ undeclared (first use in this function)
ls_test.c:10: error: (Each undeclared identifier is reported only once
ls_test.c:10: error: for each function it appears in.)
ls_test.c:13: warning: incompatible implicit declaration of built-in function ‘printf’
ls_test.c:15: warning: incompatible implicit declaration of built-in function ‘exit’
求帮助 :em09


页首
 用户资料  
 
2 楼 
 文章标题 : Re: 在《unix环境高级编程》中的ls核心程序编译出现错误
帖子发表于 : 2012-06-15 15:41 

注册: 2007-08-02 20:29
帖子: 21303
系统: 窓辺とうこ
送出感谢: 0 次
接收感谢: 22
apue.h 这个头文件是人家自定义的啊,你没加进去


页首
 用户资料  
 
3 楼 
 文章标题 : Re: 在《unix环境高级编程》中的ls核心程序编译出现错误
帖子发表于 : 2012-06-15 15:53 

注册: 2012-04-06 15:55
帖子: 125
送出感谢: 2
接收感谢: 0 次
是的,发现没包涵很多头文件和函数。


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 3 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 2 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译