summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/u8c/SIZE_C.h21
-rw-r--r--include/u8c/col.h1
-rw-r--r--include/u8c/dbgprint.h3
-rw-r--r--include/u8c/fmttyp.h12
-rw-r--r--include/u8c/geterr.h1
-rw-r--r--include/u8c/ver.h2
6 files changed, 21 insertions, 19 deletions
diff --git a/include/u8c/SIZE_C.h b/include/u8c/SIZE_C.h
index 7c9d1a9..1591252 100644
--- a/include/u8c/SIZE_C.h
+++ b/include/u8c/SIZE_C.h
@@ -14,17 +14,13 @@
If not, see <https://www.gnu.org/licenses/>.
*/
/* Size constant */
-# if !defined SIZE_C
+# if !defined(SIZE_C)
+# if !defined(__cplusplus)
# include <limits.h>
-# include <stdint.h>
-# if SIZE_MAX == USHRT_MAX
-# if defined(__cplusplus)
-/* C++ : Use variable initialisation. */
-# define SIZE_C(val) (unsigned short{val})
-# else
-/* C : Use compound literal. */
-# define SIZE_C(val) ((unsigned short){val})
# endif
+# if defined(__cplusplus) && __cplusplus > 0x31512l
+/* C++23 has a size_t suffix. */
+# define SIZE_C(val) val ## uz
# elif SIZE_MAX == UINT_MAX
# define SIZE_C(val) val
# elif SIZE_MAX == ULONG_MAX
@@ -32,12 +28,17 @@
# elif SIZE_MAX == ULLONG_MAX
# define SIZE_C(val) val ## ull
# elif SIZE_MAX == UINTMAX_MAX
-# define SIZE_C(val) UINTMAX_C(val)
+# include <stdint.h>
+# define SIZE_C(val) (UINTMAX_C(val))
# 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
# endif
diff --git a/include/u8c/col.h b/include/u8c/col.h
index 54a2b4e..9096608 100644
--- a/include/u8c/col.h
+++ b/include/u8c/col.h
@@ -16,6 +16,7 @@
/* Colour */
# if !defined(u8c_sym_col)
# define u8c_sym_col
+# include <stdint.h>
# define u8c_col_azure (UINT32_C(0x3DA9E1))
# define u8c_col_ash (UINT32_C(0xD2D2CC))
# define u8c_col_black (UINT32_C(0x444747))
diff --git a/include/u8c/dbgprint.h b/include/u8c/dbgprint.h
index 57cb219..fd7a460 100644
--- a/include/u8c/dbgprint.h
+++ b/include/u8c/dbgprint.h
@@ -17,13 +17,12 @@
# if !defined(u8c_dbgprint)
# if defined(NDEBUG)
# if defined(__cplusplus)
-# define u8c_dbgprint(...) static_cast<void>(0x0);
+# define u8c_dbgprint(...) (static_cast<void>(0x0));
# else
# define u8c_dbgprint(...) ((void)0x0)
# endif
# else
# include <u8c/print.h>
-# include <stdint.h>
# include <stdio.h>
# define u8c_dbgprint(...) u8c_print(stderr,__VA_ARGS__)
# endif
diff --git a/include/u8c/fmttyp.h b/include/u8c/fmttyp.h
index e81e774..d9b27de 100644
--- a/include/u8c/fmttyp.h
+++ b/include/u8c/fmttyp.h
@@ -18,12 +18,12 @@
# define u8c_sym_fmttyp
enum u8c_fmttyp {
u8c_fmttyp_bgcol, /* Background colour */
- u8c_fmttyp_bgcol0, /* Background colour #0 */
- u8c_fmttyp_chr, /* Character */
+ u8c_fmttyp_bgcol0, /* Background colour #0 */
+ u8c_fmttyp_chr, /* Character */
u8c_fmttyp_fgcol, /* Foreground colour */
- u8c_fmttyp_fgcol0, /* Foreground colour #0 */
- u8c_fmttyp_int, /* Integer */
- u8c_fmttyp_str, /* String */
- u8c_fmttyp_uint, /* Unsigned integer */
+ u8c_fmttyp_fgcol0, /* Foreground colour #0 */
+ u8c_fmttyp_int, /* Integer */
+ u8c_fmttyp_str, /* String */
+ u8c_fmttyp_uint, /* Unsigned integer */
};
# endif
diff --git a/include/u8c/geterr.h b/include/u8c/geterr.h
index 279f1fb..d20499f 100644
--- a/include/u8c/geterr.h
+++ b/include/u8c/geterr.h
@@ -16,6 +16,7 @@
/* Get error */
# if !defined(u8c_sym_geterr)
# define u8c_sym_geterr
+# include <stddef.h>
# include <stdint.h>
# if defined(__cplusplus)
extern "C" {
diff --git a/include/u8c/ver.h b/include/u8c/ver.h
index a626a0c..c754571 100644
--- a/include/u8c/ver.h
+++ b/include/u8c/ver.h
@@ -16,5 +16,5 @@
/* Version */
# if !defined(u8c_ver)
# include <stdint.h>
-# define u8c_ver (UINT64_C(0x5))
+# define u8c_ver (UINT64_C(0x6))
# endif