From d88a95cd83403fed764d930a87b2f74e8899dda2 Mon Sep 17 00:00:00 2001 From: Saksham Goyal Date: Thu, 9 Oct 2025 13:48:44 -0400 Subject: [PATCH] Get C++ and C compilers working --- .gitignore | 1 + src/external/win32_clipboard.h | 10 +--------- src/platforms/rcore_desktop_glfw.c | 8 +++++--- src/rcore.c | 8 +++++++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index ac4f016e4..8ffffa9af 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ packages/ *.so *.so.* *.dll +*.obj # Emscripten emsdk diff --git a/src/external/win32_clipboard.h b/src/external/win32_clipboard.h index fdaec92f7..0b4d4bbdf 100644 --- a/src/external/win32_clipboard.h +++ b/src/external/win32_clipboard.h @@ -13,7 +13,7 @@ unsigned char* Win32GetClipboardImageData(int* width, int* height, unsigned long #include #include -// NOTE: These search for architecture is taken from "Windows.h", and it's necessary if we really don't wanna import windows.h +// NOTE: These search for architecture is taken from "Windows.h", and it's necessary if we really don't wanna import windows.h // and still make it compile on msvc, because import indirectly importing "winnt.h" (e.g. ) can cause problems is these are not defined. #if !defined(_X86_) && !defined(_68K_) && !defined(_MPPC_) && !defined(_IA64_) && !defined(_AMD64_) && !defined(_ARM_) && !defined(_ARM64_) && !defined(_ARM64EC_) && defined(_M_IX86) #define _X86_ @@ -92,13 +92,6 @@ unsigned char* Win32GetClipboardImageData(int* width, int* height, unsigned long typedef int WINBOOL; -// typedef HANDLE HGLOBAL; - -#if !defined(HWND) && !defined(_MSC_VER) -#define HWND void* -#else -typedef struct HWND__ *HWND; -#endif #if !defined(_WINUSER_) || !defined(WINUSER_ALREADY_INCLUDED) @@ -371,4 +364,3 @@ static int GetPixelDataOffset(BITMAPINFOHEADER bih) } #endif // WIN32_CLIPBOARD_IMPLEMENTATION // EOF - diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index cdf5f58b2..aeb53fe5b 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -56,10 +56,12 @@ // Support retrieving native window handlers #if defined(_WIN32) - typedef void *PVOID; - typedef PVOID HANDLE; + #if !defined(HWND) && !defined(_MSVC_LANG) + #define HWND void* + #elif !defined(HWND) && defined(_MSVC_LANG) + typedef struct HWND__ *HWND; + #endif #include "../external/win32_clipboard.h" - typedef HANDLE HWND; #define GLFW_EXPOSE_NATIVE_WIN32 #define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h #include "GLFW/glfw3native.h" diff --git a/src/rcore.c b/src/rcore.c index 91daea9fd..5fdfe21d2 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -519,8 +519,14 @@ static void RecordAutomationEvent(void); // Record frame events (to internal eve #endif #if defined(_WIN32) && !defined(PLATFORM_DESKTOP_RGFW) +#ifdef __cplusplus +extern "C" { +#endif // NOTE: We declare Sleep() function symbol to avoid including windows.h (kernel32.lib linkage required) __declspec(dllimport) void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime() +#ifdef __cplusplus +} +#endif #endif #if !defined(SUPPORT_MODULE_RTEXT) @@ -2522,7 +2528,7 @@ int MakeDirectory(const char *dirPath) // Create final directory if (!DirectoryExists(pathcpy)) MKDIR(pathcpy); RL_FREE(pathcpy); - + // In case something failed and requested directory // was not successfully created, return -1 if (!DirectoryExists(dirPath)) return -1;