Browse Source

WinMain is specified by the Win32 API as having extern "C" linkage

Fixes https://github.com/libsdl-org/SDL/issues/8814
Sam Lantinga 1 year ago
parent
commit
9a77813df0
1 changed files with 13 additions and 0 deletions
  1. 13 0
      include/SDL3/SDL_main_impl.h

+ 13 - 0
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__)