linux平台数据类型

来源:互联网 发布:腾讯抄袭 知乎 编辑:程序博客网 时间:2024/06/06 12:59

一些为了跨平台的数据类型,使用了很奇怪的类型,所以,包了一个头文件<stdint.h>

16位平台

char       1个字节8位
short     2个字节16位
int         2个字节16位
long       4个字节32位
指针       2个字节

32位平台

char       1个字节8位
short     2个字节16位
int         4个字节32位
long       4个字节
long long 8个字节
指针       4个字节

64位平台

char       1个字节
short     2个字节
int         4个字节
long       8个字节(区别)
long long 8个字节
指针     8个字节(区别)

一共定义了如下数据类型。

int8_t·int16_t· int32_t· int64_t· int_fast8_t· int_fast16_t· int_fast32_t· int_fast64_t· int_least8_t· int_least16_t· int_least32_t· int_least64_t

uint8_t·uint16_t· uint32_t· uint64_t· uint_fast8_t· uint_fast16_t· uint_fast32_t· uint_fast64_t· uint_least8_t· uint_least16_t· uint_least32_t· uint_least64_t

intmax_t·intptr_t· uintmax_t· uintptr_t

INT8_C·INT16_C· INT32_C· INT64_C· INT8_MAX· INT16_MAX· INT32_MAX· INT64_MAX· INT8_MIN· INT16_MIN· INT32_MIN· INT64_MIN· INT_FAST8_MAX· INT_FAST16_MAX· INT_FAST32_MAX· INT_FAST64_MAX· INT_FAST8_MIN· INT_FAST16_MIN· INT_FAST32_MIN· INT_FAST64_MIN· INT_LEAST8_MAX· INT_LEAST16_MAX· INT_LEAST32_MAX· INT_LEAST64_MAX· INT_LEAST8_MIN· INT_LEAST16_MIN· INT_LEAST32_MIN· INT_LEAST64_MIN

UINT8_C·UINT16_C· UINT32_C· UINT64_C· UINTMAX_C· UINT8_MAX· UINT16_MAX· UINT32_MAX· UINT64_MAX· UINT_FAST8_MAX· UINT_FAST16_MAX· UINT_FAST32_MAX· UINT_FAST64_MAX· UINT_LEAST8_MAX· UINT_LEAST16_MAX· UINT_LEAST32_MAX· UINT_LEAST64_MAX

INTMAX_C·INTMAX_MAX· INTMAX_MIN· INTPTR_MAX· INTPTR_MIN· PTRDIFF_MAX· PTRDIFF_MIN· SIG_ATOMIC_MAX· SIG_ATOMIC_MIN· SIZE_MAX· WCHAR_MAX· WCHAR_MIN· WINT_MAX· WINT_MIN· UINTMAX_MAX· UINTPTR_MAX

 

此处均有连接,已下是详细定义

  /* TYPE DEFINITIONS */typedef signed char int8_t;typedef short int16_t;typedef long int32_t;typedef long long int64_t;typedef unsigned char uint8_t;typedef unsigned short uint16_t;typedef unsigned long uint32_t;typedef unsigned long long uint64_t;typedef signed char int_least8_t;typedef short int_least16_t;typedef long int_least32_t;typedef long long int_least64_t;typedef unsigned char uint_least8_t;typedef unsigned short uint_least16_t;typedef unsigned long uint_least32_t;typedef unsigned long long uint_least64_t;typedef signed char int_fast8_t;typedef short int_fast16_t;typedef long int_fast32_t;typedef long long int_fast64_t;typedef unsigned char uint_fast8_t;typedef unsigned short uint_fast16_t;typedef unsigned long uint_fast32_t;typedef unsigned long long uint_fast64_t;typedef long intptr_t;typedef unsigned long uintptr_t;typedef long long intmax_t;typedef unsigned long long uintmax_t;        /* LIMIT MACROS */#define INT8_MIN    (-0x7f - 1)#define INT16_MIN   (-0x7fff - 1)#define INT32_MIN   (-0x7fffffff - 1)#define INT64_MIN   (-0x7fffffffffffffff - 1)#define INT8_MAX    0x7f [exact]#define INT16_MAX   0x7fff [exact]#define INT32_MAX   0x7fffffff [exact]#define INT64_MAX   0x7fffffffffffffff [exact]#define UINT8_MAX   0xff [exact]#define UINT16_MAX  0xffff [exact]#define UINT32_MAX  0xffffffff [exact]#define UINT64_MAX  0xffffffffffffffff [exact]#define INT_LEAST8_MIN    (-0x7f - 1)#define INT_LEAST16_MIN   (-0x7fff - 1)#define INT_LEAST32_MIN   (-0x7fffffff - 1)#define INT_LEAST64_MIN   (-0x7fffffffffffffff - 1)#define INT_LEAST8_MAX    0x7f#define INT_LEAST16_MAX   0x7fff#define INT_LEAST32_MAX   0x7fffffff#define INT_LEAST64_MAX   0x7fffffffffffffff#define UINT_LEAST8_MAX   0xff#define UINT_LEAST16_MAX  0xffff#define UINT_LEAST32_MAX  0xffffffff#define UINT_LEAST64_MAX  0xffffffffffffffff#define INT_FAST8_MIN     (-0x7f - 1)#define INT_FAST16_MIN    (-0x7fff - 1)#define INT_FAST32_MIN    (-0x7fffffff - 1)#define INT_FAST64_MIN    (-0x7fffffffffffffff - 1)#define INT_FAST8_MAX     0x7f#define INT_FAST16_MAX    0x7fff#define INT_FAST32_MAX    0x7fffffff#define INT_FAST64_MAX    0x7fffffffffffffff#define UINT_FAST8_MAX    0xff#define UINT_FAST16_MAX   0xffff#define UINT_FAST32_MAX   0xffffffff#define UINT_FAST64_MAX   0xffffffffffffffff#define INTPTR_MIN        (-0x7fffffff - 1)#define INTPTR_MAX        0x7fffffff#define UINTPTR_MAX       0xffffffff#define INT8_C(x)    (x)#define INT16_C(x)   (x)#define INT32_C(x)   ((x) + (INT32_MAX - INT32_MAX))#define INT64_C(x)   ((x) + (INT64_MAX - INT64_MAX))#define UINT8_C(x)   (x)#define UINT16_C(x)  (x)#define UINT32_C(x)  ((x) + (UINT32_MAX - UINT32_MAX))#define UINT64_C(x)  ((x) + (UINT64_MAX - UINT64_MAX))#define INTMAX_C(x)  ((x) + (INT64_MAX - INT64_MAX))#define UINTMAX_C(x) ((x) + (UINT64_MAX - UINT64_MAX))#define PTRDIFF_MIN  INT32_MIN#define PTRDIFF_MAX  INT32_MAX#define SIG_ATOMIC_MIN    INT32_MIN#define SIG_ATOMIC_MAX    INT32_MAX#define SIZE_MAX     UINT32_MAX#define WCHAR_MIN    0#define WCHAR_MAX    UINT16_MAX#define WINT_MIN     0#define WINT_MAX     UINT16_MAX#define INTMAX_MIN        (-0x7fffffffffffffff - 1)#define INTMAX_MAX        0x7fffffffffffffff#define UINTMAX_MAX       0xffffffffffffffff
0 0