stdint.h
是C標準函數庫中的頭文件,定義了具有特定位寬的整型,以及對應的宏;還列出了在其他標準頭文件中定義的整型的極限。
類型
typedef signed integer type int8_t; // optional
typedef signed integer type int16_t; // optional
typedef signed integer type int32_t; // optional
typedef signed integer type int64_t; // optional
typedef unsigned integer type uint8_t; // optional
typedef unsigned integer type uint16_t; // optional
typedef unsigned integer type uint32_t; // optional
typedef unsigned integer type uint64_t; // optional
typedef signed integer type int_fast8_t;
typedef signed integer type int_fast16_t;
typedef signed integer type int_fast32_t;
typedef signed integer type int_fast64_t;
typedef unsigned integer type uint_fast8_t;
typedef unsigned integer type uint_fast16_t;
typedef unsigned integer type uint_fast32_t;
typedef unsigned integer type uint_fast64_t;
typedef signed integer type int_least8_t;
typedef signed integer type int_least16_t;
typedef signed integer type int_least32_t;
typedef signed integer type int_least64_t;
typedef unsigned integer type uint_least8_t;
typedef unsigned integer type uint_least16_t;
typedef unsigned integer type uint_least32_t;
typedef unsigned integer type uint_least64_t;
typedef signed integer type intptr_t; // optional
typedef unsigned integer type uintptr_t; // optional
typedef unsigned integer type uintmax_t;
typedef signed integer type intmax_t;
宏
- INTN_MIN 為 -(2N-1)
- INTN_MAX 為 2N-1 - 1
- UINTN_MAX 為 2N - 1
- INT_LEASTN_MIN 為 -(2N-1)
- INT_LEASTN_MAX 為 2N-1 - 1
- UINT_LEASTN_MAX 為 2N - 1
- INT_FASTN_MIN 為 -(2N-1)
- INT_FASTN_MAX 為 2N-1 - 1
- UINT_FASTN_MAX 為 2N - 1
- INTPTR_MIN 為 -(215 - 1)
- INTPTR_MAX 為 215 - 1
- UINTPTR_MAX 為 216 - 1
- INTMAX_MIN 為 -(263 - 1)
- INTMAX_MAX 為 263 - 1
- UINTMAX_MAX 為 264 - 1
- ptrdiff_t
- PTRDIFF_MIN 為 -65535
- PTRDIFF_MAX 為 +65535
- sig_atomic_t
- SIG_ATOMIC_MIN
- SIG_ATOMIC_MAX
- size_t
- SIZE_MAX 為 +65535
- wchar_t
- WCHAR_MIN
- WCHAR_MAX
- wint_t
- WINT_MIN
- WINT_MAX
下述類似於函數的宏,把整型常量值擴展適合其數據類型。
- 位寬不少於指定值的整型常量的宏。例如:UINT64_C(0x123) 擴展為 0x123ULL
- INTN_C(value) 把有符號整型值 value 擴展以適應數據類型 int_leastN_t
- UINTN_C(value) 把無符號整型值 value 擴展以適應數據類型 uint_leastN_t
- 具有最大位寬的整型常量的宏。
- INTMAX_C(value) 把有符號整型值 value 擴展以適應數據類型 intmax_t
- UINTMAX_C(value) 把無符號整型值 value 擴展以適應數據類型 uintmax_t
參考文獻
- C99標準的 "7.18 Integer types <stdint.h> "
- http://www.cplusplus.com/reference/cstdint/(頁面存檔備份,存於互聯網檔案館)
Wikiwand in your browser!
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.