9#ifndef HPP_ALIB_LANG_INTEGERS
10#define HPP_ALIB_LANG_INTEGERS 1
19namespace alib {
namespace lang {
26 #define ALIB_SIZEOF_INTEGER
107#if defined(ALIB_SIZEOF_INTEGER ) \
108 || defined(ALIB_SIZEOF_INTGAP ) \
109 || defined(ALIB_INTGAP_TYPE ) \
110 || defined(ALIB_SIZEOF_LONGDOUBLE_REPORTED) \
111 || defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
114 #if !defined(ALIB_SIZEOF_INTEGER) \
115 || !defined(ALIB_SIZEOF_INTGAP) \
116 || !defined(ALIB_INTGAP_TYPE) \
117 || !defined(ALIB_SIZEOF_LONGDOUBLE_REPORTED) \
118 || !defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
120 #error "If one of the Compiler Symbols \
121'ALIB_SIZEOF_INTEGER', \
122'ALIB_SIZEOF_INTGAP', \
124'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
125'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
126is given (instead of letting ALib detect them), then the whole group has to be given!"
134 #if (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8 ) || defined(_WIN64)
136 #define ALIB_SIZEOF_INTEGER 8
139 #define ALIB_INTGAP_TYPE long;
140 #define ALIB_SIZEOF_INTGAP 4
142 #elif defined(__APPLE__)
143 #define ALIB_INTGAP_TYPE long;
144 #define ALIB_SIZEOF_INTGAP 8
146 #elif defined(__GNUC__) || defined(__clang__)
147 #define ALIB_INTGAP_TYPE long long;
148 #define ALIB_SIZEOF_INTGAP 8
150 # error "Cannot detect compilation platform. Please provide Symbols \
151'ALIB_SIZEOF_INTEGER', \
152'ALIB_SIZEOF_INTGAP', \
154'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
155'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
156as documented with ALib User Manual at https://alib.dev"
160 #if defined(_MSC_VER) || defined(__APPLE__)
161 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 8
163 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 16
167 #elif (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4 ) || defined(_WIN32) || defined( __arm__)
169 #define ALIB_SIZEOF_INTEGER 4
171 #if defined(__APPLE__)
172 #define ALIB_INTGAP_TYPE long;
173 #define ALIB_SIZEOF_INTGAP 4
175 #elif defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
176 #define ALIB_INTGAP_TYPE long;
177 #define ALIB_SIZEOF_INTGAP 4
179 #error "Cannot detect compilation platform. Please provide Symbols \
180'ALIB_SIZEOF_INTEGER', \
181'ALIB_SIZEOF_INTGAP', \
183'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
184'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
185as documented with ALib User Manual at https://alib.dev"
189 #if defined(_MSC_VER) || defined( __arm__)
190 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 8
191 #elif defined(__APPLE__)
192 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 16
194 # define ALIB_SIZEOF_LONGDOUBLE_REPORTED 12
199 #error "Cannot detect compilation platform. Please provide Symbols \
200'ALIB_SIZEOF_INTEGER', \
201'ALIB_SIZEOF_INTGAP', \
203'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
204'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
205as documented with ALib User Manual at https://alib.dev"
210 #if (ALIB_SIZEOF_LONGDOUBLE_REPORTED == 8)
211 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 8
212 #elif defined(__aarch64__)
213 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 16
215 # define ALIB_SIZEOF_LONGDOUBLE_WRITTEN 10
223#if ALIB_SIZEOF_INTEGER == 4
226#elif ALIB_SIZEOF_INTEGER == 8
230 #error "Compiler symbol 'ALIB_SIZEOF_INTEGER' supports only values 4 and 8."
239#define ERROR_DETECTING \
240"Cannot detect compilation platform. Please provide Symbols \
241'ALIB_SIZEOF_INTEGER', \
242'ALIB_SIZEOF_INTGAP', \
244'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
245'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
246as documented with ALib User Manual at https://alib.dev"
248static_assert(
sizeof(
integer) ==
sizeof(
uinteger ) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
249static_assert(
sizeof(
integer) ==
sizeof(size_t ) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
250static_assert(
sizeof(
integer) ==
sizeof(ptrdiff_t) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
251static_assert(
sizeof(
integer) ==
sizeof(
void* ) ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
252static_assert(
sizeof(
integer) ==
ALIB_SIZEOF_INTEGER ,
"\nSize mismatch in definition of alib::[u]integer on this platform/compiler.\n" ERROR_DETECTING);
253static_assert(
sizeof(
intGap_t) ==
ALIB_SIZEOF_INTGAP ,
"\nDefinition of symbol ALIB_SIZEOF_INTGAP not adjusted to platform/compiler.\n" ERROR_DETECTING);
254static_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);
258#if !defined(ALIB_SIZEOF_LONGDOUBLE_WRITTEN)
259 #error "Cannot detect compilation platform. Please provide Symbols \
260'ALIB_SIZEOF_INTEGER', \
261'ALIB_SIZEOF_INTGAP', \
263'ALIB_SIZEOF_LONGDOUBLE_REPORTED' or \
264'ALIB_SIZEOF_LONGDOUBLE_WRITTEN' \
265as 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.