Carbon was deprecated in OS X 10.8 and stopped working in macOS 10.15 when
support for 32-bit x86 applications was removed.

For compatibility with new versions of OS X try to extract the system version
from the kern.osproductversion sysctl, if it exists.
If it does not, fall back to Carbon's Gestalt().

--- src/engine/version.cpp.orig	2021-05-29 05:30:02.000000000 +0200
+++ src/engine/version.cpp	2023-03-17 14:05:16.000000000 +0100
@@ -9,7 +9,12 @@
 #elif FZ_UNIX
 #include <sys/utsname.h>
 #else
+#include <sys/sysctl.h>
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101500
 #include <Carbon/Carbon.h>
+#define CARBON_AVAILABLE
+#endif
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -145,13 +150,29 @@
 #elif FZ_MAC
 SystemVersion GetSystemVersion()
 {
-	SInt32 major{};
-	Gestalt(gestaltSystemVersionMajor, &major);
+	unsigned int major = 0, minor = 0;
 
-	SInt32 minor{};
-    Gestalt(gestaltSystemVersionMinor, &minor);
+	size_t vers_len = 32;
+	char vers[vers_len];
+	vers[0] = 0;
+
+	if (0 == sysctlbyname("kern.osproductversion", vers, &vers_len, NULL, 0)) {
+		char *vp = vers;
+		major = atoi(vp);
+		while (vp < (vers + vers_len) && *vp++ != '.');
+		minor = atoi(vp);
+#ifdef CARBON_AVAILABLE
+	} else {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+		/* Carbon fallback */
+		Gestalt(gestaltSystemVersionMajor, (SInt32*)&major);
+		Gestalt(gestaltSystemVersionMinor, (SInt32*)&minor);
+#pragma clang diagnostic pop
+#endif
+	}
 
-    return {static_cast<unsigned int>(major), static_cast<unsigned int>(minor)};
+	return {major, minor};
 }
 
 #else
