Unix环境高级编程开篇-"apue.h"配置


书就不多说了,被称为Unix下C编程的圣经;不过现在国内貌似部分人都喜欢向别人推荐书,我很怀疑着部分人是不是推荐的每一本都看过。这个我暂时也不敢推荐,因为我也没有看完。
这本书上几乎所有的代码都用到了作者编程的一个头文件:apue.h,但是这个不是ISO C自带的,所以需要配置一下。

我用的这本书是第三版,第三版,第三版 重要的事情说三遍

1:先去这本书的官网把源代码下载下来,传送门

2:解压

3:make

其实解压之后你会发现,目录下面有个README的文件,打开:

Read the file called DISCLAIMER.

On Freebsd, type "gmake".
On other platforms, type "make" (as long as this is gnu make).

For FAQs, updated source code, and the lost chapter, see http://www.apuebook.com.
Please direct questions, suggestions, and bug reports to sar@apuebook.com.

Steve Rago
January 2013

人家作者已经告诉你怎么做了

4:复制两个文件

这两个文件分别是:apue.h error.c两个文件分别位于(以我的电脑为例)

/home/mark/Downloads/apu.3e/include    /* apue.h */
/home/mark/Downloads/apu.3e/lib       /* error.c */

把他们拷贝到C语言默认的工作目录(以我的电脑为例)

cp ./include/apue.h ./lib/error.c /usr/include

5:在apue.h 头文件的最后一行前添加一行代码:

#include "erro.c"

最后效果如下:

#include "error.c"
#endif  /* _APUE_H */

以上

相关内容