您的位置:首页 > 运维架构 > Linux

关于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.hinternet定义
net/if.h套接字本地接口
netinet/in.hinternet地址族
netinet/tcp.h传输控制协议定义
sys/mman.h内存管理声明
sys/select.hselect函数
sys/socket.h套接字接口
sys/stat.h文件状态,如open()
sys/times.h进程时间
sys/types.h基本系统数据类型,如open()
sys/wait.h进程控制
sys/un.hunix域套接字定义


三、第三方库

如单元测试组件#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  头文件
相关文章推荐