Linux標頭檔案詳解
標頭檔案主目錄include
標頭檔案目錄中總共有32個.h標頭檔案。其中主目錄下有13個,asm子目錄中有4個,Linux子目錄中有10個,sys子目錄中有5個。這些標頭檔案各自的功能如下,具體的作用和所包含的資訊請參見第14章。
<a.out.h>:a.out標頭檔案,定義了a.out執行檔案格式和一些巨集。
<const.h>:常數符號標頭檔案,目前僅定義了i節點中i_mode欄位的各標誌位。
<ctype.h>:字元型別標頭檔案,定義了一些有關字元型別判斷和轉換的巨集。
<errno.h>:錯誤號標頭檔案,包含系統中各種出錯號。(Linus從minix中引進的)。
<fcntl.h>:檔案控制標頭檔案,用於檔案及其描述符的操作控制常數符號的定義。
<signal.h>:訊號標頭檔案,定義訊號符號常量,訊號結構以及訊號操作函式原型。
<stdarg.h>:標準引數標頭檔案,以巨集的形式定義變數引數列表。主要說明了一個型別(va_list)和3個巨集(va_start, va_arg和va_end),用於vsprintf、vprintf、vfprintf函式。
<stddef.h>:標準定義標頭檔案,定義了NULL, offsetof(TYPE, MEMBER)。
<string.h>:字串標頭檔案,主要定義了一些有關字串操作的嵌入函式。
<termios.h>:終端輸入輸出函式標頭檔案,主要定義控制非同步通訊口的終端介面。
<time.h>:時間型別標頭檔案,主要定義了tm結構和一些有關時間的函式原形。
<unistd.h>:Linux標準標頭檔案,定義了各種符號常數和型別,並聲明瞭各種函式。
<utime.h>:使用者時間標頭檔案,定義了訪問和修改時間結構以及utime()原型。
(1)體系結構相關標頭檔案子目錄include/asm
這些標頭檔案主要定義了一些與CPU體系結構密切相關的資料結構、巨集函式和變數。共4個檔案。
<asm/io.h>:I/O標頭檔案,以巨集的嵌入彙編程式形式定義對I/O埠操作的函式。
<asm/memory.h>:記憶體拷貝標頭檔案,含有memcpy()嵌入式彙編巨集函式。
<asm/segment.h>:段操作標頭檔案,定義了有關段暫存器操作的嵌入式彙編函式。
<asm/system.h>:系統標頭檔案,定義了設定或修改描述符/中斷門等的嵌入式彙編巨集。
(2)Linux核心專用標頭檔案子目錄include/linux
<linux/config.h>:核心配置標頭檔案,定義鍵盤語言和硬碟型別(HD_TYPE)可選項。
<linux/fdreg.h>:軟碟機標頭檔案,含有軟盤控制器引數的一些定義。
<linux/fs.h>:檔案系統標頭檔案,定義檔案表結構(file,buffer_head,m_inode等)。
<linux/hdreg.h>:硬碟引數標頭檔案,定義訪問硬碟暫存器埠、狀態碼和分割槽表等資訊。
<linux/head.h>:head標頭檔案,定義了段描述符的簡單結構,和幾個選擇符常量。
<linux/kernel.h>:核心標頭檔案,含有一些核心常用函式的原形定義。
<linux/mm.h>:記憶體管理標頭檔案,含有頁面大小定義和一些頁面釋放函式原型。
<linux/sched.h>: 排程程式標頭檔案,定義了任務結構task_struct、初始任務0的資料,
以及一些有關描述符引數設定和獲取的嵌入式彙編函式巨集語句。
<linux/sys.h>:系統呼叫標頭檔案,含有72個系統呼叫C函式處理程式,以"sys_"開頭。
<linux/tty.h>:tty標頭檔案,定義了有關tty_io,序列通訊方面的引數、常數。
(3)系統專用資料結構子目錄include/sys
<sys/stat.h>: 檔案狀態標頭檔案,含有檔案或檔案系統狀態結構stat{}和常量。
<sys/times.h>:定義了程序中執行時間結構tms以及times()函式原型。
<sys/types.h>:型別標頭檔案,定義了基本的系統資料型別。
<sys/utsname.h>:系統名稱結構標頭檔案。
<sys/wait.h>:等待呼叫標頭檔案,定義系統呼叫wait()和waitpid()及相關常數符號。
linux常用標頭檔案如下:
POSIX標準定義的標頭檔案
<dirent.h> 目錄項
<fcntl.h> 檔案控制
<fnmatch.h> 檔名匹配型別
<glob.h> 路徑名模式匹配型別
<grp.h> 組檔案
<netdb.h> 網路資料庫操作
<pwd.h> 口令檔案
<regex.h> 正則表示式
<tar.h> TAR歸檔值
<termios.h> 終端I/O
<unistd.h> 符號常量
<utime.h> 檔案時間
<wordexp.h> 字元擴充套件型別
-------------------------
<arpa/inet.h> INTERNET定義
<net/if.h> 套接字本地介面
<netinet/in.h> INTERNET地址族
<netinet/tcp.h> 傳輸控制協議定義
-------------------------
<sys/mman.h> 記憶體管理宣告
<sys/select.h> Select函式
<sys/socket.h> 套接字藉口
<sys/stat.h> 檔案狀態
<sys/times.h> 程序時間
<sys/types.h> 基本系統資料型別
<sys/un.h> UNIX域套接字定義
<sys/utsname.h> 系統名
<sys/wait.h> 程序控制
------------------------------
POSIX定義的XSI擴充套件標頭檔案
<cpio.h> cpio歸檔值
<dlfcn.h> 動態連結
<fmtmsg.h> 訊息顯示結構
<ftw.h> 檔案樹漫遊
<iconv.h> 程式碼集轉換使用程式
<langinfo.h> 語言資訊常量
<libgen.h> 模式匹配函式定義
<monetary.h> 貨幣型別
<ndbm.h> 資料庫操作
<nl_types.h> 訊息類別
<poll.h> 輪詢函式
<search.h> 搜尋表
<strings.h> 字串操作
<syslog.h> 系統出錯日誌記錄
<ucontext.h> 使用者上下文
<ulimit.h> 使用者限制
<utmpx.h> 使用者帳戶資料庫
-----------------------------
<sys/ipc.h> IPC(命名管道)
<sys/msg.h> 訊息佇列
<sys/resource.h>資源操作
<sys/sem.h> 訊號量
<sys/shm.h> 共享儲存
<sys/statvfs.h> 檔案系統資訊
<sys/time.h> 時間型別
<sys/timeb.h> 附加的日期和時間定義
<sys/uio.h> 向量I/O操作
------------------------------
POSIX定義的可選標頭檔案
<aio.h> 非同步I/O
<mqueue.h> 訊息佇列
<pthread.h> 執行緒
<sched.h> 執行排程
<semaphore.h> 訊號量
<spawn.h> 實時spawn介面
<stropts.h> XSI STREAMS介面
<trace.h> 事件跟蹤
3、 C/C++標頭檔案一覽
C
#i nclude <assert.h> //設定插入點
#i nclude <ctype.h> //字元處理
#i nclude <errno.h> //定義錯誤碼
#i nclude <float.h> //浮點數處理
#i nclude <iso646.h> //對應各種運算子的巨集
#i nclude <limits.h> //定義各種資料型別最值的常量
#i nclude <locale.h> //定義本地化C函式
#i nclude <math.h> //定義數學函式
#i nclude <setjmp.h> //異常處理支援
#i nclude <signal.h> //訊號機制支援
#i nclude <stdarg.h> //不定引數列表支援
#i nclude <stddef.h> //常用常量
#i nclude <stdio.h> //定義輸入/輸出函式
#i nclude <stdlib.h> //定義雜項函式及記憶體分配函式
#i nclude <string.h> //字串處理
#i nclude <time.h> //定義關於時間的函式
#i nclude <wchar.h> //寬字元處理及輸入/輸出
#i nclude <wctype.h> //寬字元分類
傳統C++
#i nclude <fstream.h> //改用<fstream>
#i nclude <iomanip.h> //改用<iomainip>
#i nclude <iostream.h> //改用<iostream>
#i nclude <strstrea.h> //該類不再支援,改用<sstream>中的stringstream
————————————————————————————————
標準C++
#i nclude <algorithm> //STL 通用演算法
#i nclude <bitset> //STL 位集容器
#i nclude <cctype> //字元處理
#i nclude <cerrno> //定義錯誤碼
#i nclude <cfloat> //浮點數處理
#i nclude <ciso646> //對應各種運算子的巨集
#i nclude <climits> //定義各種資料型別最值的常量
#i nclude <clocale> //定義本地化函式
#i nclude <cmath> //定義數學函式
#i nclude <complex> //複數類
#i nclude <csignal> //訊號機制支援
#i nclude <csetjmp> //異常處理支援
#i nclude <cstdarg> //不定引數列表支援
#i nclude <cstddef> //常用常量
#i nclude <cstdio> //定義輸入/輸出函式
#i nclude <cstdlib> //定義雜項函式及記憶體分配函式
#i nclude <cstring> //字串處理
#i nclude <ctime> //定義關於時間的函式
#i nclude <cwchar> //寬字元處理及輸入/輸出
#i nclude <cwctype> //寬字元分類
#i nclude <deque> //STL 雙端佇列容器
#i nclude <exception> //異常處理類
#i nclude <fstream> //檔案輸入/輸出
#i nclude <al> //STL 定義運算函式(代替運算子)
#i nclude <limits> //定義各種資料型別最值常量
#i nclude <list> //STL 線性列表容器
#i nclude <locale> //本地化特定資訊
#i nclude <map> //STL 對映容器
#i nclude <memory> //STL通過分配器進行的記憶體分配
#i nclude <new> //動態記憶體分配
#i nclude <numeric> //STL常用的數字操作
#i nclude <iomanip> //引數化輸入/輸出
#i nclude <iOS> //基本輸入/輸出支援
#i nclude <iosfwd> //輸入/輸出系統使用的前置宣告
#i nclude <iostream> //資料流輸入/輸出
#i nclude <istream> //基本輸入流
#i nclude <iterator> //STL迭代器
#i nclude <ostream> //基本輸出流
#i nclude <queue> //STL 佇列容器
#i nclude <set> //STL 集合容器
#i nclude <sstream> //基於字串的流
#i nclude <stack> //STL 堆疊容器
#i nclude <stdexcept> //標準異常類
#i nclude <streambuf> //底層輸入/輸出支援
#i nclude <string> //字串類
#i nclude <typeinfo> //執行期間型別資訊
#i nclude <utility> //STL 通用模板類
#i nclude <valarray> //對包含值的陣列的操作
#i nclude <vector> //STL 動態陣列容器
————————————————————————————————
C99增加的部分
#i nclude <complex.h> //複數處理
#i nclude <fenv.h> //浮點環境
#i nclude <inttypes.h> //整數格式轉換
#i nclude <stdbool.h> //布林環境
#i nclude <stdint.h> //整型環境
#i nclude <tgmath.h> //通用型別數學巨集