summaryrefslogtreecommitdiff
path: root/include/u8c/SIZE_C.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/u8c/SIZE_C.h')
-rw-r--r--include/u8c/SIZE_C.h26
1 files changed, 6 insertions, 20 deletions
diff --git a/include/u8c/SIZE_C.h b/include/u8c/SIZE_C.h
index 1591252..4a8d513 100644
--- a/include/u8c/SIZE_C.h
+++ b/include/u8c/SIZE_C.h
@@ -15,31 +15,17 @@
*/
/* Size constant */
# if !defined(SIZE_C)
-# if !defined(__cplusplus)
# include <limits.h>
-# endif
-# if defined(__cplusplus) && __cplusplus > 0x31512l
-/* C++23 has a size_t suffix. */
-# define SIZE_C(val) val ## uz
+# include <stdint.h>
+# if SIZE_MAX == USHRT_MAX
+# define SIZE_C(val) ((unsigned short)val)
# elif SIZE_MAX == UINT_MAX
# define SIZE_C(val) val
# elif SIZE_MAX == ULONG_MAX
-# define SIZE_C(val) val ## ul
+# define SIZE_C(val) val ## lu
# elif SIZE_MAX == ULLONG_MAX
-# define SIZE_C(val) val ## ull
-# elif SIZE_MAX == UINTMAX_MAX
-# include <stdint.h>
-# define SIZE_C(val) (UINTMAX_C(val))
+# define SIZE_C(val) val ## llu
# else
-/* Cannot match width; construct new element of type "size_t" */
-# if defined(__cplusplus)
-/* C++ has value initialisation. */
-# include <cstddef>
-# define SIZE_C(val) (std::size_t{val})
-# else
-/* C has compound literals. */
-# include <stddef.h>
-# define SIZE_C(val) ((size_t){val})
-# endif
+# define SIZE_C(val) ((size_t)UINTMAX_C(val))
# endif
# endif