From 118c729680d6664f793f8d88ff0b7548137847d3 Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat@gmail.com>
Date: Sat, 27 May 2023 09:38:12 -0700
Subject: [PATCH 1/2] Define __STDC_FORMAT_MACROS on systems that need it

---
 CMakeLists.txt | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git CMakeLists.txt CMakeLists.txt
index eeef181f..0bc8f2e2 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -186,6 +186,20 @@ set(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0)
 set(EXPORT_DECL "")
 
 
+# Some systems erroneously require the __STDC_FORMAT_MACROS macro to be defined
+# to get the fixed-width integer type formatter macros.
+check_cxx_source_compiles("#include <cinttypes>
+#include <cstdio>
+int main()
+{
+    int64_t i64{};
+    std::printf(\"%\" PRId64, i64);
+}"
+HAVE_STDC_FORMAT_MACROS)
+if(NOT HAVE_STDC_FORMAT_MACROS)
+    set(CPP_DEFS ${CPP_DEFS} __STDC_FORMAT_MACROS)
+endif()
+
 if(NOT WIN32)
     # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
     check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
-- 
2.40.1

