Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5513673
  • 博文数量: 922
  • 博客积分: 19333
  • 博客等级: 上将
  • 技术积分: 11226
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-27 14:33
文章分类

全部博文(922)

文章存档

2023年(1)

2020年(2)

2019年(1)

2017年(1)

2016年(3)

2015年(10)

2014年(17)

2013年(49)

2012年(291)

2011年(266)

2010年(95)

2009年(54)

2008年(132)

分类: LINUX

2011-12-26 12:10:13

++++++APUE读书笔记-02UNIX标准和实现-08系统基本类型++++++

 

8、系统基本数据类型
================================================
 以前,特定的C数据类型和特定的UNIX系统变量相关联。例如,设备的主设备号和次设备号码以前存放在一个16位的短整数类型中,其中的8位用于主设备号码,另外的8位用于次设备号码。但是,许多大的系统中,设备号码的值会多于256个,所以需要一种特定的技术(实际上,solaris使用32位表示设备号码:14位用于主设备号,18位用于次设备号)。
 头文件定义了一些实现独立的数据类型,被称作系统基本数据类型。大多数这些数据类型也都定义在其他的头文件中。这些数据类型通过C语言的typedef关键字,在其头文件中有所定义,大多数以"_t"结束。下图列出了我们本书中遇到的许多系统基本数据类型。

一些通用的系统原始数据类型
+-------------------------------------------------------------------------------------------+
|     Type     |                                Description                                 |
|--------------+----------------------------------------------------------------------------|
| caddr_t      | core address (Section 14.9)                                                |
|--------------+----------------------------------------------------------------------------|
| clock_t      | counter of clock ticks (process time) (Section 1.10)                       |
|--------------+----------------------------------------------------------------------------|
| comp_t       | compressed clock ticks (Section 8.14)                                      |
|--------------+----------------------------------------------------------------------------|
| dev_t        | device numbers (major and minor) (Section 4.23)                            |
|--------------+----------------------------------------------------------------------------|
| fd_set       | file descriptor sets (Section 14.5.1)                                      |
|--------------+----------------------------------------------------------------------------|
| fpos_t       | file position (Section 5.10)                                               |
|--------------+----------------------------------------------------------------------------|
| gid_t        | numeric group IDs                                                          |
|--------------+----------------------------------------------------------------------------|
| ino_t        | i-node numbers (Section 4.14)                                              |
|--------------+----------------------------------------------------------------------------|
| mode_t       | file type, file creation mode (Section 4.5)                                |
|--------------+----------------------------------------------------------------------------|
| nlink_t      | link counts for directory entries (Section 4.14)                           |
|--------------+----------------------------------------------------------------------------|
| off_t        | file sizes and offsets (signed) (lseek, Section 3.6)                       |
|--------------+----------------------------------------------------------------------------|
| pid_t        | process IDs and process group IDs (signed) (Sections 8.2 and 9.4)          |
|--------------+----------------------------------------------------------------------------|
| ptrdiff_t    | result of subtracting two pointers (signed)                                |
|--------------+----------------------------------------------------------------------------|
| rlim_t       | resource limits (Section 7.11)                                             |
|--------------+----------------------------------------------------------------------------|
| sig_atomic_t | data type that can be accessed atomically (Section 10.15)                  |
|--------------+----------------------------------------------------------------------------|
| sigset_t     | signal set (Section 10.11)                                                 |
|--------------+----------------------------------------------------------------------------|
| size_t       | sizes of objects (such as strings) (unsigned) (Section 3.7)                |
|--------------+----------------------------------------------------------------------------|
| ssize_t      | functions that return a count of bytes (signed) (read, write, Section 3.7) |
|--------------+----------------------------------------------------------------------------|
| time_t       | counter of seconds of calendar time (Section 1.10)                         |
|--------------+----------------------------------------------------------------------------|
| uid_t        | numeric user IDs                                                           |
|--------------+----------------------------------------------------------------------------|
| wchar_t      | can represent all distinct character codes                                 |
+-------------------------------------------------------------------------------------------+
 
 通过用这种方式来定义这些数据类型,我们就不用由于各种系统的不同,而向我们的应用程序中加入和实现细节相关的东西,进行编译。我们在本书后面遇到这些数据类型的时候,将会讲述每种数据类型的作用。

参考:

 

 

阅读(788) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~