2、inttypes.h: 定义扩展整数类型的printf和scanf格式控制字符串,用于实现可移植的格式化输出或输入。还定义了一些与stdlib.h中对应的基本算术函数和转换函数。imaxabs和imaxdiv函数类似于stdlib.h中的abs和div函数,imaxabs(x)返回最大类型整数x的绝对值,imaxdiv(n,d)计算最大类型整数的除法n/d,得出的商和余数分别放在imaxdiv_t结构的quot和rem成员中。strtoimax和strtoumax函数将字符串转换成最大类型的整数,与stdlib.h中的strtol和strtoul类似。wcstoimax和wcstoumax函数将宽字符串转换成最大类型的整数,与wchar.h中的wcstol和wcstoul类似。
/* ISO C99: 7.8 整数类型的格式转换 <inttypes.h> */
#ifndef _INTTYPES_H
#define _INTTYPES_H 1
#include <features.h>
/* 获取类型定义 */
#include <stdint.h>
/* 获取wchar_t的定义,但我们自己不能定义 */
#ifndef ____gwchar_t_defined
# ifdef __cplusplus
# define __gwchar_t wchar_t
# elif defined __WCHAR_TYPE__
typedef __WCHAR_TYPE__ __gwchar_t;
# else
# define __need_wchar_t
# include <stddef.h>
typedef wchar_t __gwchar_t;
# endif
# define ____gwchar_t_defined 1
#endif
/* ISO C99标准指出,这些宏应该只在被请求到的时候才定义 */
#if !defined __cplusplus || defined __STDC_FORMAT_MACROS
# if __WORDSIZE == 64
# define __PRI64_PREFIX "l"
# define __PRIPTR_PREFIX "l"
# else
# define __PRI64_PREFIX "ll"
# define __PRIPTR_PREFIX
# endif
/* 表示输出格式控制串的宏 */
/* 十进制格式 */
# define PRId8 "d" /* 表示8位准确类型的输出格式控制串 */
# define PRId16 "d"
# define PRId32 "d"
# define PRId64 __PRI64_PREFIX "d"
# define PRIdLEAST8 "d" /* 表示8位最小类型的输出格式控制串 */
# define PRIdLEAST16 "d"
# define PRIdLEAST32 "d"
# define PRIdLEAST64 __PRI64_PREFIX "d"
# define PRIdFAST8 "d"
# define PRIdFAST16 __PRIPTR_PREFIX "d"
# define PRIdFAST32 __PRIPTR_PREFIX "d"
# define PRIdFAST64 __PRI64_PREFIX "d"
# define PRIi8 "i"
# define PRIi16 "i"
# define PRIi32 "i"
# define PRIi64 __PRI64_PREFIX "i"
# define PRIiLEAST8 "i"
# define PRIiLEAST16 "i"
# define PRIiLEAST32 "i"
# define PRIiLEAST64 __PRI64_PREFIX "i"
# define PRIiFAST8 "i"
# define PRIiFAST16 __PRIPTR_PREFIX "i"
# define PRIiFAST32 __PRIPTR_PREFIX "i"
# define PRIiFAST64 __PRI64_PREFIX "i"
/* 八进制格式 */
# define PRIo8 "o"
# define PRIo16 "o"
# define PRIo32 "o"
# define PRIo64 __PRI64_PREFIX "o"
# define PRIoLEAST8 "o"
# define PRIoLEAST16 "o"
# define PRIoLEAST32 "o"
# define PRIoLEAST64 __PRI64_PREFIX "o"
# define PRIoFAST8 "o"
# define PRIoFAST16 __PRIPTR_PREFIX "o"
# define PRIoFAST32 __PRIPTR_PREFIX "o"
# define PRIoFAST64 __PRI64_PREFIX "o"
/* 无符号整数格式 */
# define PRIu8 "u"
# define PRIu16 "u"
# define PRIu32 "u"
# define PRIu64 __PRI64_PREFIX "u"
# define PRIuLEAST8 "u"
# define PRIuLEAST16 "u"
# define PRIuLEAST32 "u"
# define PRIuLEAST64 __PRI64_PREFIX "u"
# define PRIuFAST8 "u"
# define PRIuFAST16 __PRIPTR_PREFIX "u"
# define PRIuFAST32 __PRIPTR_PREFIX "u"
# define PRIuFAST64 __PRI64_PREFIX "u"
/* 小写十六进制格式 */
# define PRIx8 "x"
# define PRIx16 "x"
# define PRIx32 "x"
# define PRIx64 __PRI64_PREFIX "x"
# define PRIxLEAST8 "x"
# define PRIxLEAST16 "x"
# define PRIxLEAST32 "x"
# define PRIxLEAST64 __PRI64_PREFIX "x"
# define PRIxFAST8 "x"
# define PRIxFAST16 __PRIPTR_PREFIX "x"
# define PRIxFAST32 __PRIPTR_PREFIX "x"
# define PRIxFAST64 __PRI64_PREFIX "x"
/* 大写十六进制格式 */
# define PRIX8 "X"
# define PRIX16 "X"
# define PRIX32 "X"
# define PRIX64 __PRI64_PREFIX "X"
# define PRIXLEAST8 "X"
# define PRIXLEAST16 "X"
# define PRIXLEAST32 "X"
# define PRIXLEAST64 __PRI64_PREFIX "X"
# define PRIXFAST8 "X"
# define PRIXFAST16 __PRIPTR_PREFIX "X"
# define PRIXFAST32 __PRIPTR_PREFIX "X"
# define PRIXFAST64 __PRI64_PREFIX "X"
/* 打印intmax_t和uintmax_t的格式宏 */
# define PRIdMAX __PRI64_PREFIX "d"
# define PRIiMAX __PRI64_PREFIX "i"
# define PRIoMAX __PRI64_PREFIX "o"
# define PRIuMAX __PRI64_PREFIX "u"
# define PRIxMAX __PRI64_PREFIX "x"
# define PRIXMAX __PRI64_PREFIX "X"