clibs
Tiny but handy utility libraries for C
integer.h
Go to the documentation of this file.
1 
61 #if _WIN32 && _MSC_VER
62  typedef signed __int8 int8_t;
63  typedef unsigned __int8 uint8_t;
64  typedef signed __int16 int16_t;
65  typedef unsigned __int16 uint16_t;
66  typedef signed __int32 int32_t;
67  typedef unsigned __int32 uint32_t;
68  typedef signed __int64 int64_t;
69  typedef unsigned __int64 uint64_t;
70  #define INT8_IS_DEFINED
71  #define UINT8_IS_DEFINED
72  #define INT16_IS_DEFINED
73  #define UINT16_IS_DEFINED
74  #define INT32_IS_DEFINED
75  #define UINT32_IS_DEFINED
76  #define INT64_IS_DEFINED
77  #define UINT64_IS_DEFINED
78 #elif __STDC_VERSION__ >= 199901L
79  #include <stdint.h>
80  #define INT8_IS_DEFINED
81  #define UINT8_IS_DEFINED
82  #define INT16_IS_DEFINED
83  #define UINT16_IS_DEFINED
84  #define INT32_IS_DEFINED
85  #define UINT32_IS_DEFINED
86  #define INT64_IS_DEFINED
87  #define UINT64_IS_DEFINED
88 #else
89  #include "_sizeof_data_type.h"
90  #if _SIZEOF_CHAR >= 32
91  typedef signed char int32_t;
92  typedef unsigned char uint32_t;
93  #define INT32_IS_DEFINED
94  #define UINT32_IS_DEFINED
95  #elif _SIZEOF_CHAR >= 16
96  typedef signed char int16_t;
97  typedef unsigned char uint16_t;
98  #define INT16_IS_DEFINED
99  #define UINT16_IS_DEFINED
100  #else
101  typedef signed char int8_t;
102  typedef unsigned char uint8_t;
103  #define INT8_IS_DEFINED
104  #define UINT8_IS_DEFINED
105  #endif
106 
107  #if _SIZEOF_SHORT >= 32
108  typedef signed short int32_t;
109  typedef unsigned short uint32_t;
110  #define INT32_IS_DEFINED
111  #define UINT32_IS_DEFINED
112  #else
113  #ifndef INT16_IS_DEFINED
114  typedef signed short int16_t;
115  typedef unsigned short uint16_t;
116  #define INT16_IS_DEFINED
117  #define UINT16_IS_DEFINED
118  #endif
119  #endif
120 
121  #if _SIZEOF_INT >= 64
122  #if __APPLE__
123  typedef unsigned long uint64_t;
124  #define INT64_IS_DEFINED
125  #define UINT64_IS_DEFINED
126  #else
127  typedef signed int int64_t;
128  typedef unsigned int uint64_t;
129  #define INT64_IS_DEFINED
130  #define UINT64_is_DEFINED
131  #endif
132  #elif _SIZEOF_INT >= 32
133  #ifndef INT32_IS_DEFINED
134  typedef signed int int32_t;
135  typedef unsigned int uint32_t;
136  #define INT32_IS_DEFINED
137  #define UINT32_IS_DEFINED
138  #endif
139  #else
140  #ifndef INT16_IS_DEFINED
141  typedef signed int int16_t;
142  typedef unsigned int int16_t;
143  #define INT16_IS_DEFINED
144  #define UINT16_IS_DEFINED
145  #endif
146  #endif
147 
148  #if _SIZEOF_LONG >= 64
149  #if __APPLE__
150  typedef unsigned long uint64_t;
151  #define INT64_IS_DEFINED
152  #define UINT64_IS_DEFINED
153  #else
154  typedef signed long int64_t;
155  typedef unsigned long uint64_t;
156  #define INT64_IS_DEFINED
157  #define UINT64_IS_DEFINED
158  #endif
159  #else
160  #ifndef INT32_IS_DEFINED
161  typedef signed long int32_t;
162  typedef unsigned long uint32_t;
163  #define INT32_IS_DEFINED
164  #define UINT32_IS_DEFINED
165  #endif
166  #endif
167 
168  /* `long long int` in C89 is defined as a compiler extension
169  in either GCC or Clang. */
170  #if __GNUC__ || __clang__
171  #if __APPLE__
172  #if !defined(INT64_IS_DEFINED) && _SIZEOF_LONG_LONG <= 64
173  typedef unsigned long long uint64_t;
174  #define INT64_IS_DEFINED
175  #define UINT64_IS_DEFINED
176  #endif
177  #else
178  #if !defined(INT64_IS_DEFINED) && _SIZEOF_LONG_LONG <= 64
179  typedef signed long long int64_t;
180  typedef unsigned long long uint64_t;
181  #define INT64_IS_DEFINED
182  #define UINT64_IS_DEFINED
183  #endif
184  #endif
185  #endif
186 #endif
unsigned long long uint64_t
64 bit unsigned integer
Definition: integer.h:180
signed short int16_t
16 bit signed integer
Definition: integer.h:114
unsigned short uint16_t
16 bit unsigned integer
Definition: integer.h:115
unsigned long uint32_t
32 bit unsigned integer
Definition: integer.h:162
signed char int8_t
8 bit signed integer
Definition: integer.h:101
signed long int32_t
32 bit signed integer
Definition: integer.h:161
signed long long int64_t
64 bit signed integer
Definition: integer.h:179
unsigned char uint8_t
8 bit unsigned interger
Definition: integer.h:102