标准C库的学习-P.J.PLAUCER The Standard C Library读书笔记(一)

     看了PLAUCER的书。才发现对经典的标准C库知之甚少,用过但没系统的学习过,现在通过PLAUCER的书好好的研究一下吧!

     PLAUCER对库的定义:A library is a collection of program components that can be reused in many programs. Most programming languages include some form of library. The programming language C is no exception. It began accreting useful functions right from the start. These functions help you classify characters, manipulate character strings, read input, and write output -to name just a few categories of services。

     标准C库共在15个头文件中做出声明,还包含对相关的类型和宏的定义:<assert.h><locale.h><stddef.h><stype.h><math.h><stdio.h><errno.h><setjmp.h><stdlib.h><float.h><signal.h><string.h><limits.h><stdarg.h><time.h>。

     对于头文件的定义有Idempotence、mutual independence和declaration equivalence三条准则:

就我自己的理解所谓的Idempotence就是为了不让头文件重复定义,在开头用宏把头文件保护起来:

                                                        #ifndef _STDIO_H

                                                        #define _STDIO_H

                                                        ..../* the body of <stdio.h> */

                                                        #endif

这样已经定义的头文件就不会被再次定义。

mutual independence就是在不同的头文件中可能有一个名字进行了分别定义,为了保证不出错我们也要利用宏包这样的定义保护起来:

                                                       #ifndef _SIZE_T
                                                       #define _SIZE_T
                                                       typedef unsigned int size_t;
                                                       #endif

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值