From 9fefbcbc108bd96debd774a799d89cba4a8ffed7 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 18 Jun 2012 17:51:22 -0500 Subject: [PATCH] Fixing JUCE build errors on MinGW --- CMakeLists.txt | 5 +++-- .../modules/juce_core/native/juce_BasicNativeHeaders.h | 8 +++++--- .../modules/juce_core/native/juce_win32_ComSmartPtr.h | 3 +-- JuceLibraryCode/modules/juce_core/text/juce_String.cpp | 2 +- .../juce_gui_basics/native/juce_win32_Windowing.cpp | 7 ++++++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4b9193..35830a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,15 +15,16 @@ MESSAGE("--------------------------------------------------------------") # Failing to do so will cause your program to be terminated when a png # or a jpeg exception is thrown on linux or macosx. IF (CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions") ENDIF(CMAKE_COMPILER_IS_GNUCC) IF (WIN32) + SET_PROPERTY(GLOBAL PROPERTY JUCE_WINDOWS "JUCE_WINDOWS") SET_PROPERTY(GLOBAL PROPERTY JUCE_MINGW "JUCE_MINGW") ADD_DEFINITIONS(-DDONT_AUTOLINK_TO_JUCE_LIBRARY) - SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -march=i686 ") + SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -march=i686") SET(JUCE_PLATFORM_SPECIFIC_LIBRARIES kernel32.lib diff --git a/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h b/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h index 40ef0b1..8ceaf1b 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h @@ -87,6 +87,10 @@ #define _WIN32_IE 0x0400 #endif + #if JUCE_MINGW + #include + #endif + #include #include #include @@ -102,9 +106,7 @@ #include #include - #if JUCE_MINGW - #include - #else + #if ! JUCE_MINGW #include #include #endif diff --git a/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h b/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h index d4373b9..8032999 100644 --- a/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -132,12 +132,11 @@ public: { #if ! JUCE_MINGW if (refId == __uuidof (ComClass)) { AddRef(); *result = dynamic_cast (this); return S_OK; } + if (refId == IID_IUnknown) { AddRef(); *result = dynamic_cast (this); return S_OK; } #else jassertfalse; // need to find a mingw equivalent of __uuidof to make this possible #endif - if (refId == IID_IUnknown) { AddRef(); *result = dynamic_cast (this); return S_OK; } - *result = 0; return E_NOINTERFACE; } diff --git a/JuceLibraryCode/modules/juce_core/text/juce_String.cpp b/JuceLibraryCode/modules/juce_core/text/juce_String.cpp index bb9e560..9ef1479 100644 --- a/JuceLibraryCode/modules/juce_core/text/juce_String.cpp +++ b/JuceLibraryCode/modules/juce_core/text/juce_String.cpp @@ -443,7 +443,7 @@ namespace NumberToStringConverters else { // Use a locale-free sprintf where possible (not available on linux AFAICT) - #if JUCE_WINDOWS + #if JUCE_WINDOWS && ! JUCE_MINGW len = (size_t) _sprintf_l (buffer, "%.9g", _create_locale (LC_NUMERIC, "C"), n); #elif JUCE_MAC || JUCE_IOS len = (size_t) sprintf_l (buffer, nullptr, "%.9g", n); diff --git a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index b3d4371..6c306f2 100644 --- a/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/JuceLibraryCode/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -54,7 +54,12 @@ void* getUser32Function (const char* functionName) // (NB: this function also us HMODULE user32Mod = GetModuleHandleA ("user32.dll"); jassert (user32Mod != 0); - return static_cast (GetProcAddress (user32Mod, functionName)); + #if ! JUCE_MINGW + return static_cast (GetProcAddress (user32Mod, functionName)); + #else + jassertfalse; // need to find a mingw equivalent + #endif + } //==============================================================================