From 2e9c07ca97b895c693872347b2d1b48feb21731f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 22 Feb 2021 15:56:02 +0300
Subject: [PATCH] fix macOS builds
---
src/SDL12_compat.c | 6 +-----
src/SDL12_compat_objc.m | 14 +++++++++++++-
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 39b7cb1..3267028 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -886,11 +886,7 @@ static void error_dialog(const char *errorMsg)
MessageBoxA(NULL, errorMsg, "Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
}
#elif defined(__APPLE__)
-static void error_dialog(const char *errorMsg)
-{
- NSString* msg = [NSString stringWithCString:errorMsg encoding:NSASCIIStringEncoding];
- NSRunCriticalAlertPanel (@"Error", @"%@", @"OK", nil, nil, msg);
-}
+extern void error_dialog(const char *errorMsg);
#else
static void error_dialog(const char *errorMsg)
{
diff --git a/src/SDL12_compat_objc.m b/src/SDL12_compat_objc.m
index cb7ffbc..8ad06ac 100644
--- a/src/SDL12_compat_objc.m
+++ b/src/SDL12_compat_objc.m
@@ -26,15 +26,27 @@
#ifdef __MACOSX__
#include <Cocoa/Cocoa.h>
+#if __GNUC__ >= 4
+#define SDL12_PRIVATE __attribute__((visibility("hidden")))
+#else
+#define SDL12_PRIVATE __private_extern__
+#endif
+
/* This has to be in a separate, Objective-C source file because it calls
into Cocoa. The issue is that SDL 1.2 apps on macOS are statically linked
with SDLmain, which does something mac-specific that conflicts with SDL2
before the app's main() is even called, and we have to counteract that. */
-void sdl12_compat_macos_init(void)
+SDL12_PRIVATE void sdl12_compat_macos_init(void)
{
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
}
+
+SDL12_PRIVATE void error_dialog(const char *errorMsg)
+{
+ NSString* msg = [NSString stringWithCString:errorMsg encoding:NSASCIIStringEncoding];
+ NSRunCriticalAlertPanel (@"Error", @"%@", @"OK", nil, nil, msg);
+}
#endif
/* vi: set ts=4 sw=4 expandtab: */