Linux下的標頭檔案
1、 Linux中一些標頭檔案的作用: <assert.h>:ANSI C。提供斷言,assert(表示式) <glib.h>:GCC。GTK,GNOME的基礎庫,提供很多有用的函式,如有資料結構操作函式。使用glib只需要包含<glib.h> <dirent.h>:GCC。資料夾操作函式。struct dirent,struct DIR,opendir(),closedir(),readdir(),readdir64()等 <ctype.h>:ANSI C。字元測試函式。isdigit(),islower()等 <errno.h>:ANSI C。檢視錯誤程式碼errno是除錯程式的一個重要方法。當linuc C api函式發生異常時,一般會將errno變數(需include errno.h)賦一個整數值,不同的值表示不同的含義,可以通過檢視該值推測出錯的原因。在實際程式設計中用這一招解決了不少原本看來莫名其妙的問題。比較 麻煩的是每次都要去linux原始碼裡面查詢錯誤程式碼的含義,現在把它貼出來,以後需要查時就來這裡看了。來自linux 2.4.20-18的核心程式碼中的/usr/include/asm/errno.h <getopt.h>:處理命令列引數。getopt()
2、
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 #include <assert.h> //設定插入點 #include <ctype.h> //字元處理 #include <errno.h> //定義錯誤碼 #include <float.h> //浮點數處理 #include <iso646.h> //對應各種運算子的巨集 #include <limits.h> //定義各種資料型別最值的常量 #include <locale.h> //定義本地化C函式 #include <math.h> //定義數學函式 #include <setjmp.h> //異常處理支援 #include <signal.h> //訊號機制支援 #include <stdarg.h> //不定引數列表支援 #include <stddef.h> //常用常量 #include <stdio.h> //定義輸入/輸出函式 #include <stdlib.h> //定義雜項函式及記憶體分配函式 #include <string.h> //字串處理 #include <time.h> //定義關於時間的函式 #include <wchar.h> //寬字元處理及輸入/輸出 #include <wctype.h> //寬字元分類
傳統C++ #include <fstream.h> //改用 #include <iomanip.h> //改用 #include <iostream.h> //改用 #include <strstrea.h> //該類不再支援,改用中的stringstream ————————————————————————————————
標準C++ #include //STL 通用演算法 #include //STL 位集容器 #include //字元處理 #include //定義錯誤碼 #include //浮點數處理 #include //對應各種運算子的巨集 #include //定義各種資料型別最值的常量 #include //定義本地化函式 #include //定義數學函式 #include //複數類 #include //訊號機制支援 #include //異常處理支援 #include //不定引數列表支援 #include //常用常量 #include //定義輸入/輸出函式 #include //定義雜項函式及記憶體分配函式 #include //字串處理 #include //定義關於時間的函式 #include //寬字元處理及輸入/輸出 #include //寬字元分類 #include //STL 雙端佇列容器 #include //異常處理類 #include //檔案輸入/輸出 #include //STL 定義運算函式(代替運算子) #include //定義各種資料型別最值常量 #include //STL 線性列表容器 #include //本地化特定資訊 #include
C99增加的部分 #include <complex.h> //複數處理 #include <fenv.h> //浮點環境 #include <inttypes.h> //整數格式轉換 #include <stdbool.h> //布林環境 #include <stdint.h> //整型環境 #include <tgmath.h> //通用型別數學巨集