JUCE icon indicating copy to clipboard operation
JUCE copied to clipboard

[Bug]: JUCE 6.1.5 fails to compile UUIDGetter template in MinGW on x86

Open Birch-san opened this issue 2 years ago • 3 comments

Detailed steps on how to reproduce the bug

Containerised repro using JUCE audio plugin example:

git clone https://github.com/Birch-san/juce-repro.git
cd juce-repro
docker build --build-arg LLVM_MINGW_VER=20211002 --build-arg XARCH=i686 .

Note: we are using llvm-mingw 20211002 because there is an unrelated compilation failure (https://github.com/juce-framework/JUCE/issues/1028) on llvm-mingw 20220209.

The last JUCE version on which I was able to successfully cross-compile an audio plugin for x86, was JUCE 6.1.2. See https://github.com/juce-framework/JUCE/issues/985 for the problems with compiling uuidof() that have ensued since then. The issue I'm filing today is the latest incarnation of the uuidof() problem

In x86 build only, we fail to compile juce_gui_basics.cpp, because of the template function UUIDGetter:

In file included from /linux_native/include/JUCE-6.1.5/modules/juce_gui_basics/juce_gui_basics.cpp:309:
/linux_native/include/JUCE-6.1.5/modules/juce_gui_basics/native/accessibility/juce_win32_ComInterfaces.h:179:1: error: class template specialization of 'UUIDGetter' not in a namespace enclosing 'juce'
JUCE_COMCLASS (IRawElementProviderFragmentRoot, "620ce2a5-ab8f-40a9-86cb-de3c75599b58") : public IUnknown
^
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:45:5: note: expanded from macro 'JUCE_COMCLASS'
    JUCE_DECLARE_UUID_GETTER (name, guid) \
    ^
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:41:24: note: expanded from macro 'JUCE_DECLARE_UUID_GETTER'
    template <> struct UUIDGetter<name> { static CLSID get()  { return uuidFromString (uuid); } };
                       ^
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:31:34: note: explicitly specialized declaration is here
 template <typename Type> struct UUIDGetter { static CLSID get() { jassertfalse; return {}; } };
                                 ^

What is the expected behaviour?

Successful compilation of x86 audio plugin.

Operating systems

Linux

What versions of the operating systems?

Ubuntu 22.04 cross-compiling for Windows 7 x86.

Architectures

32-bit

Stacktrace

Full error here:  
https://gist.github.com/Birch-san/5cc9ca55e789f38f7593ed6ebb033801

In file included from /linux_native/include/JUCE-6.1.5/modules/juce_gui_basics/juce_gui_basics.cpp:309:
/linux_native/include/JUCE-6.1.5/modules/juce_gui_basics/native/accessibility/juce_win32_ComInterfaces.h:179:1: error: class template specialization of 'UUIDGetter' not in a namespace enclosing 'juce'
JUCE_COMCLASS (IRawElementProviderFragmentRoot, "620ce2a5-ab8f-40a9-86cb-de3c75599b58") : public IUnknown
^
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:45:5: note: expanded from macro 'JUCE_COMCLASS'
    JUCE_DECLARE_UUID_GETTER (name, guid) \
    ^
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:41:24: note: expanded from macro 'JUCE_DECLARE_UUID_GETTER'
    template <> struct UUIDGetter<name> { static CLSID get()  { return uuidFromString (uuid); } };
                       ^
/linux_native/include/JUCE-6.1.5/modules/juce_core/native/juce_win32_ComSmartPtr.h:31:34: note: explicitly specialized declaration is here
 template <typename Type> struct UUIDGetter { static CLSID get() { jassertfalse; return {}; } };
                                 ^

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

I have not tested against the develop branch

Code of Conduct

  • [X] I agree to follow the Code of Conduct

Birch-san avatar Feb 14 '22 00:02 Birch-san

Same problem here. And it's i686, mingw 32bit, only. And I'm not using lvvm/clang.

@reuk https://github.com/juce-framework/JUCE/commit/f429647ae90a010550c453006f7f1170e74d5718 and https://github.com/juce-framework/JUCE/commit/640194c87857978c86fcc4f3a0a5f675e323435c didn't fix this.

kmatheussen avatar Apr 12 '22 09:04 kmatheussen

I fixed it in my build with this crude patch:

kjetil@tt:~/radium/pluginhost$ git diff .
diff --git a/pluginhost/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h b/pluginhost/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h
index b1f4bcb97..edddc5c68 100644
--- a/pluginhost/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h
+++ b/pluginhost/JuceLibraryCode/modules/juce_core/native/juce_win32_ComSmartPtr.h
@@ -23,7 +23,7 @@
 namespace juce
 {
 
-#if (JUCE_MINGW && JUCE_32BIT) || (! defined (_MSC_VER) && ! defined (__uuidof))
+#if 0
  #ifdef __uuidof
   #undef __uuidof
  #endif

For some reason, it didn't work just doing

- #if (JUCE_MINGW && JUCE_32BIT) || (! defined (_MSC_VER) && ! defined (__uuidof))
- #if JUCE_MINGW || (! defined (_MSC_VER) && ! defined (__uuidof))

Maybe the JUCE_32BIT macro isn't set properly in mingw?

kmatheussen avatar Apr 12 '22 09:04 kmatheussen

(forget that last thing about the JUCE_32BIT macro. :-)

kmatheussen avatar Apr 12 '22 09:04 kmatheussen