stdint.h — Integer types

The stdint.h header defines integer types, limits of specified width integer types, limits of other integer types and macros for integer constant expressions.

Note: For the exact width integer types, minimum width integer types and limits of specified width integer types we support bit sizes N with the values 8, 16, 32, and 64.
The following exact width integer types are defined.
  • intN_t
  • uintN_t
The following minimum-width integer types are defined.
  • int_leastN_t
  • uint_leastN_t
The following fastest minimum-width integer types are defined. These types are the fastest to operate with among all integer types that have at least the specified width.
  • int_fastN_t
  • uint_fastN_t
The following greatest-width integer types are defined. These types hold the value of any signed/unsigned integer type.
Note: Requires long long to be available.
  • intmax_t
  • uintmax_t
The following integer types capable of holding object pointers are defined.
  • intptr_t
  • uintptr_t

Object-like macros for limits of integer types: Additional object-like macros provided by the stdint.h header are described.

Note: For the exact width integer limits, minimum width integer limits and limits of specified width integer types we support bit sizes N with the values 8, 16, 32, and 64.
Macros for limits of exact width integer types:
  • INTN_MAX
  • INTN_MIN
  • UINTN_MAX
Macros for limits of minimum width integer types:
  • INT_LEASTN_MAX
  • INT_LEASTN_MIN
  • UINT_LEASTN_MAX
Macros for limits of fastest minimum width integer types:
  • INT_FASTN_MAX
  • INT_FASTN_MIN
  • UINT_FASTN_MAX
Macros for limits of greatest width integer types:
Note: Requires long long to be available.
  • INTMAX_MAX
  • INTMAX_MIN
  • UINTMAX_MAX
Macros for limits of pointer integer types:
  • INTPTR_MAX
  • INTPTR_MIN
  • UINTPTR_MAX
Macros for limits of ptrdiff_t:
  • PTRDIFF_MAX
  • PTRDIFF_MIN
Macros for limits of sig_atomic_t:
  • SIG_ATOMIC_MAX
  • SIG_ATOMIC_MIN
Macro for limit of size_t:
  • SIZE_MAX
Macros for limits of wchar_t:
  • WCHAR_MAX
  • WCHAR_MIN
Macros for limits of wint_t:
  • WINT_MAX
  • WINT_MIN

Function-like macros for integer constants: Additional function-like macros provided by the stdint.h header are described.

Note: For the following macro for minimum width integer constants, we support bit sizes N with the values 8, 16, 32, and 64.
Macros for minimum width integer constants:
  • INTN_C(value)
  • UINTN_C(value)
Example:
#define _ISOC99_SOURCE
#include <inttypes.h>      
#include <stdio.h>        
                                
                                
 int main(void)                 
 {                              
   uint32_t a = UINT32_C(1234); 
   printf("%u\n",a );             
                                
 }                              
            
Output

1234
Example of how the compiler expands the macro:
|     uint32_t a = UINT32_C(1234); 
+     uint32_t a = 1234U;          
Macros for greatest width integer constants:
Note: Requires long long to be available.
  • INTMAX_C(value)
  • UINTMAX_C(value)

Example:

/* long long required */
#define _ISOC99_SOURCE
#include <inttypes.h>      
#include <stdio.h>        
                                
                                
 int main(void)                 
 {                              
   intmax_t a = INTMAX_C(45268724); 
   printf("%jd\n",a );             
                                
 }                                                            
            
Output

45268724
Example of how the compiler expands the macro with the LP64 compiler option:
| intmax_t a = INTMAX_C(45268724);
+ intmax_t a = 45268724L;                    
Otherwise the compiler expands to:
| intmax_t a = INTMAX_C(45268724);
+ intmax_t a = 45268724LL;