9#ifndef HPP_ALIB_LANG_INTEGERS
10#define HPP_ALIB_LANG_INTEGERS 1
12#if !defined(HPP_ALIB) && !defined(ALIB_DOX)
16#if !defined (_GLIBCXX_CSTDINT) && !defined (_CSTDINT_)
20#if !defined (_GLIBCXX_CSTDDEF) && !defined (_CSTDDEF_)
24namespace alib {
namespace lang {
31 #define ALIB_SIZEOF_INTEGER
120#if defined(ALIB_SIZEOF_INTEGER ) \
121 || defined(ALIB_SIZEOF_INTGAP ) \
122 || defined(ALIB_INTGAP_TYPE ) \
123 || defined(ALIB_SIZEOF_LONGDOUBLE_REPORTED) \
124 || defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
127 #if !defined(ALIB_SIZEOF_INTEGER) \
128 || !defined(ALIB_SIZEOF_INTGAP) \
129 || !defined(ALIB_INTGAP_TYPE) \
130 || !defined(ALIB_SIZEOF_LONGDOUBLE_REPORTED) \
131 || !defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
133 #error "If one of the Compiler Symbols \
134'ALIB_SIZEOF_INTEGER', \
135'ALIB_SIZEOF_INTGAP', \
137'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
138'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
139is given (instead of letting ALib detect them), then the whole group has to be given!"
147 #if (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8 ) || defined(_WIN64)
149 #define ALIB_SIZEOF_INTEGER 8
152 #define ALIB_INTGAP_TYPE long;
153 #define ALIB_SIZEOF_INTGAP 4
155 #elif defined(__APPLE__)
156 #define ALIB_INTGAP_TYPE long;
157 #define ALIB_SIZEOF_INTGAP 8
159 #elif defined(__GNUC__) || defined(__clang__)
160 #define ALIB_INTGAP_TYPE long long;
161 #define ALIB_SIZEOF_INTGAP 8
163 # error "Can not detect compilation platform. Please provide Symbols \
164'ALIB_SIZEOF_INTEGER', \
165'ALIB_SIZEOF_INTGAP', \
167'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
168'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
169as documented with ALib User Manual at https://alib.dev"
173 #if defined(_MSC_VER) || defined(__APPLE__)
174 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 8
176 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 16
180 #elif (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4 ) || defined(_WIN32) || defined( __arm__)
182 #define ALIB_SIZEOF_INTEGER 4
184 #if defined(__APPLE__)
185 #define ALIB_INTGAP_TYPE long;
186 #define ALIB_SIZEOF_INTGAP 4
188 #elif defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
189 #define ALIB_INTGAP_TYPE long;
190 #define ALIB_SIZEOF_INTGAP 4
192 #error "Can not detect compilation platform. Please provide Symbols \
193'ALIB_SIZEOF_INTEGER', \
194'ALIB_SIZEOF_INTGAP', \
196'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
197'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
198as documented with ALib User Manual at https://alib.dev"
202 #if defined(_MSC_VER) || defined( __arm__)
203 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 8
204 #elif defined(__APPLE__)
205 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 16
207 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 12
212 #error "Can not detect compilation platform. Please provide Symbols \
213'ALIB_SIZEOF_INTEGER', \
214'ALIB_SIZEOF_INTGAP', \
216'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
217'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
218as documented with ALib User Manual at https://alib.dev"
223 #if (ALIB_SIZEOF_LONGDOUBLE_REPORTED == 8)
224 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 8
225 #elif defined(__aarch64__)
226 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 16
228 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 10
236#if ALIB_SIZEOF_INTEGER == 4
239#elif ALIB_SIZEOF_INTEGER == 8
243 #error "Compiler symbol 'ALIB_SIZEOF_INTEGER' supports only values 4 and 8."
252#define ERROR_DETECTING \
253"Can not detect compilation platform. Please provide Symbols \
254'ALIB_SIZEOF_INTEGER', \
255'ALIB_SIZEOF_INTGAP', \
257'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
258'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
259as documented with ALib User Manual at https://alib.dev"
261static_assert(
sizeof(
integer) ==
sizeof(
uinteger ) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
262static_assert(
sizeof(
integer) ==
sizeof(
size_t ) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
263static_assert(
sizeof(
integer) ==
sizeof(ptrdiff_t) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
264static_assert(
sizeof(
integer) ==
sizeof(
void* ) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
265static_assert(
sizeof(
integer) ==
ALIB_SIZEOF_INTEGER ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
266static_assert(
sizeof(
intGap_t) ==
ALIB_SIZEOF_INTGAP ,
"\nDefinition of symbol ALIB_SIZEOF_INTGAP not adjusted to platform/compiler.\n" ERROR_DETECTING);
267static_assert(
sizeof(
long double) ==
ALIB_SIZEOF_LONGDOUBLE_REPORTED,
"\nSize mismatch in definition of macro ALIB_SIZEOF_LONGDOUBLE_REPORTED on this platform/compiler.\n" ERROR_DETECTING);
271#if !defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
272 #error "Can not detect compilation platform. Please provide Symbols \
273'ALIB_SIZEOF_INTEGER', \
274'ALIB_SIZEOF_INTGAP', \
276'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
277'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
278as documented with ALib User Manual at https://alib.dev"
#define ALIB_SIZEOF_INTEGER
#define ALIB_SIZEOF_INTGAP
#define ALIB_SIZEOF_LONGDOUBLE_REPORTED
platform_specific intGap_t
platform_specific uintGap_t
platform_specific integer
platform_specific uinteger
lang::uinteger uinteger
Type alias in namespace alib.
lang::intGap_t intGap_t
Type alias in namespace alib.
lang::uintGap_t uintGap_t
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.