关于linux环境下c语言内核开发中头文件分类
2018-03-08 15:40
375 查看
一、标准c库(C89版)
ANSI C(C89)标准库函数共有15个头文件。ctype.h包含13个函数
math.h包含22个函数
signal.h包含2个函数
stdio.h包含41个函数
stdlib.h包含28个函数
string.h包含22个函数
time.h包含9个函数
共计137个函数
1995年,NA1批准3个头文件(iso646.h,wchar.h,wctype.h)增加到c标准函数库中
C99标准增加6个头文件(complex.h,fenv.h,inttypes.h,stdbool.h,stdint.h,tgmath.h)
C11标准新增5个头文件(stdalign.h,stdatomic.h,stdnoreturn.h,threads.h,uchar.h)
至此,C标准函数库共计29个头文件
assert.h | 断言:提供了一个名为assert的宏,用于验证程序的假设,为假时输出信息,assert(1 == 0) |
ctype.h | 字符分类函数:提供一系列函数用于测试传进来的字符是否为字母或数字或标点符号,大小写字母转换 |
errno.h | 错误码返回:定义整数变量errno,在函数发生错误时提供错误信息,定义宏#define EPERM 1 |
float.h | 提供浮点型范围和精度,用于数值分析 |
limits.h | 检测整型数据数据类型的范围 |
locale.h | 用于在处理多种自然语言的软件编程设计时,把程序调整到特定的区域设置,如日期格式和货币符号 |
math.h | 定义各种数学函数 |
setjmp.h | 分别承担非局部标号和goto作用 |
signal.h | 信号处理部分:用作进程间通信,报告异常行为等 |
stdarg.h | 使程序接收可变参数,如int check(int a, ...); |
stddef.h | 定义各种变量类型和宏 |
stdio.h | 标准输入输出:如printf(),scanf() |
stdlib.h | 标准库头文件:如malloc(),calloc(),realloc(),free(),system(),atoi(),rand(),exit()等 |
string.h | 字符串相关函数,如strcat() |
time.h | 时间相关函数,如time(); |
二、系统调用
头文件 | 描述 |
---|---|
dirent.h | 目录项,如opendir(),readdir()等 |
fcntl.h | 文件控制,如open() |
fnmatch.h | 文件名匹配类型 |
glob.h | 路径名模式匹配类型 |
unistd.h | 符号常量,如fork(),pipe(),read(),write(),close()等 |
utime.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 | 文件状态,如open() |
sys/times.h | 进程时间 |
sys/types.h | 基本系统数据类型,如open() |
sys/wait.h | 进程控制 |
sys/un.h | unix域套接字定义 |
三、第三方库
如单元测试组件#include <CUnit.h>#include <Basic.h>
#include <TestDB.h>
四、自己写的头文件
附录:
<ctype.h>头文件
#include <ctype.h> int isalnum(int c); //检查参数c是否为英文字母或阿拉伯数字,是则返回TRUE,否则返回NULL int isalpha(int c); //检查参数c是否为英文字母,是则返回TRUE,否则返回NULL int isascii(int c); //检查参数c是否为ASCII字符,即判断c的范围是否在0到127之间,是则返回TRUE,否则返回NULL int isblank(int c); // int iscntrl(int c); //检查参数c是否为ASCII控制码,即判断c的范围是否是0到30之间,是则返回TRUE,否则返回NULL int isdigit(int c); //检查参数c是否为阿拉伯数字0到9,是则返回TRUE,否则返回NULL int isgraph(int c); //检查参数c是否为可打印字符,若c对应的ASCII码可打印且非空格字符则返回TRUE,否则返回NULL int islower(int c); //检查参数c是否为小写英文字母,是则返回TRUE,否则返回NULL int isprint(int c); //检查参数c是否为可打印字符,若c对应的ASCII码可打印,包含空格字符,则返回TRUE,否则返回NULL int isspace(int c); //检查参数c是否为空格字符,即判断是否为空格(' ')、定位字符('\t')、CR('\r')、换行('\n')、垂直定位字符('\v')或翻页('\f')的情况 int ispunct(int c); //检查参数c是否为标点符号或特殊符号,返回TRUE表示c为非空格、非数字和非英文字母 int isupper(int c); //检查参数c是否为大些英文字母,是则返回TRUE,否则返回NULL int isxdigit(int c); //检查c是否为16进制数,只要c为下列其中一个情况则返回TRUE,16进制数:0123456789ABCDEF int toascii(int c); //返回转换成功的ACSII码字符值 int toupper(int c); //若参数c为小写字母则将对应的大写字母返回 int tolower(int c); //若参数c为大写字母则将对应的小写字母返回
<stdlib.h>头文件
#include <stdlib.h> void _Exit(int c); long a64l(const char *); void abort(void); int abs(int); double atof(const char *nptr); int atoi(const char *nptr); long atol(const char *nptr); long long atoll(const char *); void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); void *calloc(size_t, size_t); div_t div(int, int); char *ecvt(double, int, int *restrict, int *restrict); (LEGACY) double erand48(unsigned short[3]); void exit(int); char *fcvt(double, int, int *restrict, int *restrict); (LEGACY) char *gcvt(double number, size_t ndigits, char *buf); (LEGACY) void free(void *); char *getenv(const char *); int getsubopt(char **, char *const*, char **); int grantpt(int); char *initstate(unsigned, char *, size_t); long jrand48(unsigned short[3]); char *l64a(long); long labs(long); void lcong48(unsigned short[7]); ldiv_t ldiv(long, long); long long llabs(long long); lldiv_t lldiv(long long, long long); long lrand48(void); double strtod(const char *nptr, char **endptr); long int strtol(const char *nptr, char **endptr, int base); unsigned long int strtoul(const char *nptr, char **endptr, int base); int tolower(int c); void *calloc(size_t nmemb, size_t size); void *malloc(size_t size); void free(void *ptr); int rand(void); void srand(unsigned int seed);
<unistd.h>头文件
#include <unistd.h> size_t getpagesize(void); void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offsize); //#include <sys/mman.h> void *munmap(void *start, size_t length); //#include <sys/mman.h> int gettimeofday(struct timeval *tv, struct timezone *tz); //#include <sys/time.h> int settimeofday(const struct timeval *tv, const struct timezone *tz); int fsync(int fd); int sync(void); size_t read(int fd, void *buf, size_t count); size_t write(int fd, const void *buf, size_t count);
<time.h>头文件
#include <time.h> char *asctime(const struct tm *timeptr); char *ctime(const time_t *timep); struct tm *gmtime(const time_t *timep); struct tm *localtime(const time_t *timep); time_t mktime(struct tm *timeptr); time_t time(time_t *t);
<string.h>头文件
#include <string.h> int bcmp(const void *s1, const void *s2, int n); void bcopy(const void*src, void *dest, int n); void bzero(void *s, int n); char *index(const char *s, int c); void *memccpy(void *dest, const void *src, int c, size_t n); void *memchr(const void *s, int c, size_t n); int memcmp(const void *s1, const void *s2, size_t n); void *memcpy(void *dest, const void*src, size_t n); void *memmove(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); char *rindex(const char *s, int c); int strcasecmp(const char *s1, const char *s2); char *strcat(char *dest, const char*src); char *strchr(const char *s, int c); int strcmp(const char *s1, const char *s2); char *strdup(const char *s); size_t strlen(const char *s); char *strstr(const char *shaystack, const char *needle); char *strtok(char *s, const char *delim);
<math.h>头文件
#include <math.h> double acos(double x); double asin(double x); ...
<sys/types.h>头文件
#include <sys/types.h> int create(const char *pathname, mode_tmode); //#include <sys/stat.h> #include <fcntl.h> int open(const char *pathname, int flags); //#include <sys/stat.h> #include <fcntl.h> int open(const char *pathname, int flags, mode_t mode); //#include <sys/stat.h> #include <fcntl.h> off_t lseek(int fildes, off_t offset, int whence); //#include <unistd.h>
<fcntl.h>头文件
#include <fcntl.h> int fcntl(int fd, int cmd); //#include <unistd.h>
<sys/file.h>头文件
#include <sys/file.h> int flock(int fd, int operation);参考:https://wenku.baidu.com/view/e426f96a011ca300a6c39012.html
相关文章推荐
- 网摘:Linux环境下学C语言开发要学些什么
- 关于linux 开发环境的编码问题(VIM)
- Linux驱动开发环境配置(内核源码树构造)
- 关于Linux环境变量文件
- 关于OPhone开发环境下重装ADT后无法找到库文件和无法启动模拟器的问题处理
- 关于linux环境变量文件
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】虚拟机下Linux和windows的文件共享――共享方式
- Linux驱动开发环境搭建之一(建立内核树)
- 搭建linux C语言开发环境——redhat9+vim+ctags+taglist+cscope
- 转贴一个好的文章,关于android开发环境在Linux(fedora14)
- 关于Linux内核开发的管理
- Linux环境下学C语言开发要学些什么
- Linux驱动开发环境配置(内核源码树构造)
- linux环境搭建和arm开发板环境搭建 续 分类: 嵌入式开发学习 2011-03-22 22:58 2558人阅读 评论(3) 收藏
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】虚拟机下Linux和windows的文件共享――mount方式
- qt 在linux环境下的搭建 (自己整理) 分类: 嵌入式开发学习 2011-04-29 20:54 6033人阅读 评论(0) 收藏
- 关于linux环境变量文件
- 关于 c语言的编译 和编译后程序的运行 分类: 嵌入式开发学习 2011-03-29 19:57 909人阅读 评论(0) 收藏
- Linux环境下学C语言开发要学些什么
- linux环境搭建和arm开发板环境搭建 分类: 嵌入式开发学习 2011-03-17 22:59 1403人阅读 评论(1) 收藏