LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1177|回复: 1

编译错误。。。

[复制链接]
发表于 2006-11-15 19:25:55 | 显示全部楼层 |阅读模式
#include "apue.h"
#define BUFFSIZE 4096
int
main(void){
        int n;
        char buf[BUFFSIZE];
        while ((n=read(STDIN_FILENO,buf,n))>0)
                if (write(STDOUT_FILENO,buf,n)!=n)
                        err_sys("write error");
        if (n<0)
                err_sys("read error");
        exit(0);
}
运行gcc 3-3.c后如下:
3-3.c:1:18: apue.h: No such file or directory
3-3.c: In function `main':
3-3.c:7: error: `STDIN_FILENO' undeclared (first use in this function)
3-3.c:7: error: (Each undeclared identifier is reported only once
3-3.c:7: error: for each function it appears in.)
3-3.c:8: error: `STDOUT_FILENO' undeclared (first use in this function)

此代码是unix高级编程里一例子,为什么会出这样的错误?
我用的是debian,不知道C的编译环境有没有缺少一些库文件。。。
发表于 2006-11-15 19:32:21 | 显示全部楼层
3-3.c:1:18: apue.h: No such file or directory

没有apue.h头文件。请先下载APUE附带的源代码,或者直接应用系统的头文件,如<unistd.h>之类
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表