From 9a77813df0404e518013724925aacd060b60b8dd Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 10 Jan 2024 06:25:49 -0800
Subject: [PATCH] WinMain is specified by the Win32 API as having extern "C"
linkage
Fixes https://github.com/libsdl-org/SDL/issues/8814
---
include/SDL3/SDL_main_impl.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/SDL3/SDL_main_impl.h b/include/SDL3/SDL_main_impl.h
index 33a3d4347a20..2ba34271fbc8 100644
--- a/include/SDL3/SDL_main_impl.h
+++ b/include/SDL3/SDL_main_impl.h
@@ -100,6 +100,10 @@ int main(int argc, char *argv[])
#endif /* _MSC_VER && ! __GDK__ */
/* This is where execution begins [windowed apps and GDK] */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#if defined( UNICODE ) && UNICODE
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw)
#else /* ANSI */
@@ -112,6 +116,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
(void)sw;
return SDL_RunApp(0, NULL, SDL_main, NULL);
}
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
/* end of __WIN32__ and __GDK__ impls */
#elif defined(__WINRT__)
@@ -163,10 +170,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#pragma comment(lib, "runtimeobject.lib")
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
return SDL_RunApp(0, NULL, SDL_main, NULL);
}
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
/* end of WinRT impl */
#elif defined(__NGAGE__)