CC++——库头文件及其作用
1、 一些頭文件的作用:
:ANSI C。提供斷言,assert(表達(dá)式)
:GCC。GTK,GNOME的基礎(chǔ)庫,提供很多有用的函數(shù),如有數(shù)據(jù)結(jié)構(gòu)操作函數(shù)。使用glib只需要包含
:GCC。文件夾操作函數(shù)。struct dirent,struct DIR,opendir(),closedir(),readdir(),readdir64()等
:ANSI C。字符測試函數(shù)。isdigit(),islower()等
:ANSI C。查看錯誤代碼errno是調(diào)試程序的一個重要方法。當(dāng)linuc C api函數(shù)發(fā)生異常時,一般會將errno變量(需include errno.h)賦一個整數(shù)值,不同的值表示不同的含義,可以通過查看該值推測出錯的原因。在實際編程中用這一招解決了不少原本看來莫名其妙的問題。比較麻煩的是每次都要去linux源代碼里面查找錯誤代碼的含義,現(xiàn)在把它貼出來,以后需要查時就來這里看了。來自linux 2.4.20-18的內(nèi)核代碼中的/usr/include/asm/errno.h
:處理命令行參數(shù)。getopt()
linux常用頭文件如下:
POSIX標(biāo)準(zhǔn)定義的頭文件
<dirent.h> 目錄項
<fcntl.h> 文件控制
<fnmatch.h> 文件名匹配類型
<glob.h> 路徑名模式匹配類型
<grp.h> 組文件
<netdb.h> 網(wǎng)絡(luò)數(shù)據(jù)庫操作
<pwd.h> 口令文件
<regex.h> 正則表達(dá)式
<tar.h> TAR歸檔值
<termios.h> 終端I/O
<unistd.h> 符號常量
<utime.h> 文件時間
<wordexp.h> 字符擴(kuò)展類型
————————————————————————————————————————————————————————————————
<arpa/inet.h> INTERNET定義
<net/if.h> 套接字本地接口
<netinet/in.h> INTERNET地址族
<netinet/tcp.h> 傳輸控制協(xié)議定義
————————————————————————————————————————————————————————————————
<sys/mman.h> 內(nèi)存管理聲明
<sys/select.h> Select函數(shù)
<sys/socket.h> 套接字借口
<sys/stat.h> 文件狀態(tài)
<sys/times.h> 進(jìn)程時間
<sys/types.h> 基本系統(tǒng)數(shù)據(jù)類型
<sys/un.h> UNIX域套接字定義
<sys/utsname.h> 系統(tǒng)名
<sys/wait.h> 進(jìn)程控制
————————————————————————————————————————————————————————————————
POSIX定義的XSI擴(kuò)展頭文件
<cpio.h> cpio歸檔值
<dlfcn.h> 動態(tài)鏈接
<fmtmsg.h> 消息顯示結(jié)構(gòu)
<ftw.h> 文件樹漫游
<iconv.h> 代碼集轉(zhuǎn)換使用程序
<langinfo.h> 語言信息常量
<libgen.h> 模式匹配函數(shù)定義
<monetary.h> 貨幣類型
<ndbm.h> 數(shù)據(jù)庫操作
<nl_types.h> 消息類別
<poll.h> 輪詢函數(shù)
<search.h> 搜索表
<strings.h> 字符串操作
<syslog.h> 系統(tǒng)出錯日志記錄
<ucontext.h> 用戶上下文
<ulimit.h> 用戶限制
<utmpx.h> 用戶帳戶數(shù)據(jù)庫
————————————————————————————————————————————————————————————————
<sys/ipc.h> IPC(命名管道)
<sys/msg.h> 消息隊列
<sys/resource.h>資源操作
<sys/sem.h> 信號量
<sys/shm.h> 共享存儲
<sys/statvfs.h> 文件系統(tǒng)信息
<sys/time.h> 時間類型
<sys/timeb.h> 附加的日期和時間定義
<sys/uio.h> 矢量I/O操作
————————————————————————————————————————————————————————————————
POSIX定義的可選頭文件
<aio.h> 異步I/O
<mqueue.h> 消息隊列
<pthread.h> 線程
<sched.h> 執(zhí)行調(diào)度
<semaphore.h> 信號量
<spawn.h> 實時spawn接口
<stropts.h> XSI STREAMS接口
<trace.h> 事件跟蹤
3、 C/C++頭文件一覽
C
#include <assert.h> //設(shè)定插入點
#include <ctype.h> //字符處理
#include <errno.h> //定義錯誤碼
#include <float.h> //浮點數(shù)處理
#include <iso646.h> //對應(yīng)各種運(yùn)算符的宏
#include <limits.h> //定義各種數(shù)據(jù)類型最值的常量
#include <locale.h> //定義本地化C函數(shù)
#include <math.h> //定義數(shù)學(xué)函數(shù)
#include <setjmp.h> //異常處理支持
#include <signal.h> //信號機(jī)制支持
#include <stdarg.h> //不定參數(shù)列表支持
#include <stddef.h> //常用常量
#include <stdio.h> //定義輸入/輸出函數(shù)
#include <stdlib.h> //定義雜項函數(shù)及內(nèi)存分配函數(shù)
#include <string.h> //字符串處理
#include <time.h> //定義關(guān)于時間的函數(shù)
#include <wchar.h> //寬字符處理及輸入/輸出
#include <wctype.h> //寬字符分類
傳統(tǒng)C++
#include <fstream.h> //改用<fstream>
#include <iomanip.h> //改用<iomainip>
#include <iostream.h> //改用<iostream>
#include <strstrea.h> //該類不再支持,改用<sstream>中的stringstream
————————————————————————————————————————————————————————————————
標(biāo)準(zhǔn)C++
#include <algorithm> //STL 通用算法
#include <bitset> //STL 位集容器
#include <cctype> //字符處理
#include <cerrno> //定義錯誤碼
#include <cfloat> //浮點數(shù)處理
#include <ciso646> //對應(yīng)各種運(yùn)算符的宏
#include <climits> //定義各種數(shù)據(jù)類型最值的常量
#include <clocale> //定義本地化函數(shù)
#include <cmath> //定義數(shù)學(xué)函數(shù)
#include <complex> //復(fù)數(shù)類
#include <csignal> //信號機(jī)制支持
#include <csetjmp> //異常處理支持
#include <cstdarg> //不定參數(shù)列表支持
#include <cstddef> //常用常量
#include <cstdio> //定義輸入/輸出函數(shù)
#include <cstdlib> //定義雜項函數(shù)及內(nèi)存分配函數(shù)
#include <cstring> //字符串處理
#include <ctime> //定義關(guān)于時間的函數(shù)
#include <cwchar> //寬字符處理及輸入/輸出
#include <cwctype> //寬字符分類
#include <deque> //STL 雙端隊列容器
#include <exception> //異常處理類
#include <fstream> //文件輸入/輸出
#include <functional> //STL 定義運(yùn)算函數(shù)(代替運(yùn)算符)
#include <limits> //定義各種數(shù)據(jù)類型最值常量
#include <list> //STL 線性列表容器
#include <locale> //本地化特定信息
#include <map> //STL 映射容器
#include <memory> //STL通過分配器進(jìn)行的內(nèi)存分配
#include <new> //動態(tài)內(nèi)存分配
#include <numeric> //STL常用的數(shù)字操作
#include <iomanip> //參數(shù)化輸入/輸出
#include <ios> //基本輸入/輸出支持
#include <iosfwd> //輸入/輸出系統(tǒng)使用的前置聲明
#include <iostream> //數(shù)據(jù)流輸入/輸出
#include <istream> //基本輸入流
#include <iterator> //STL迭代器
#include <ostream> //基本輸出流
#include <queue> //STL 隊列容器
#include <set> //STL 集合容器
#include <sstream> //基于字符串的流
#include <stack> //STL 堆棧容器
#include <stdexcept> //標(biāo)準(zhǔn)異常類
#include <streambuf> //底層輸入/輸出支持
#include <string> //字符串類
#include <typeinfo> //運(yùn)行期間類型信息
#include <utility> //STL 通用模板類
#include <valarray> //對包含值的數(shù)組的操作
#include <vector> //STL 動態(tài)數(shù)組容器
————————————————————————————————————————————————————————————————
C99增加的部分
#include <complex.h> //復(fù)數(shù)處理
#include <fenv.h> //浮點環(huán)境
#include <inttypes.h> //整數(shù)格式轉(zhuǎn)換
#include <stdbool.h> //布爾環(huán)境
#include <stdint.h> //整型環(huán)境
#include <tgmath.h> //通用類型數(shù)學(xué)宏
如需查看stdio.h可以通過man stdio.h
轉(zhuǎn)載于:https://www.cnblogs.com/sun-frederick/p/4772500.html
總結(jié)
以上是生活随笔為你收集整理的CC++——库头文件及其作用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第七章 路由器、交换机及其操作系统介绍
- 下一篇: 轻松搞定RabbitMQ(二)——工作队