2012年5月3日 星期四

stdint.h

/usr/include/stdint.h
每次用都要打一次好麻煩,花點時間整理一下

#include <stdint.h>
typedef int8_t s8;      //signed char
typedef int16_t s16;    //short int
typedef int32_t s32;    //int
typedef uint64_t s64;   //long int or long long int (by os_32/64)

typedef uint_least8_t u8;   //unsigned char
typedef uint_least16_t u16; //unsigned short int
typedef uint_least32_t u32; //unsigned int
typedef uint_least64_t u64; //unsigned long int

看了一下stdint.h,內容最下方還有這些東西:


/* Minimum of signed integral types.  */
# define INT8_MIN       (-128)
# define INT16_MIN      (-32767-1)
# define INT32_MIN      (-2147483647-1)
# define INT64_MIN      (-__INT64_C(9223372036854775807)-1)
/* Maximum of signed integral types.  */
# define INT8_MAX       (127)
# define INT16_MAX      (32767)
# define INT32_MAX      (2147483647)
# define INT64_MAX      (__INT64_C(9223372036854775807))
/* Maximum of unsigned integral types.  */
# define UINT8_MAX      (255)
# define UINT16_MAX     (65535)
# define UINT32_MAX     (4294967295U)
# define UINT64_MAX     (__UINT64_C(18446744073709551615))
....

ref : stdint.h

沒有留言:

張貼留言