juce-framework / JUCE

JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, LV2 and AAX audio plug-ins.
https://juce.com
Other
6.65k stars 1.75k forks source link

Visual Studio 2015 : '_InterlockedDecrement': ambiguous call to overloaded function #163

Closed xaviergodart closed 7 years ago

xaviergodart commented 7 years ago

Hi there,

I have been playing with the faust2juce script of the Faust language which generate a ready to compile JUCE project. Here is the generated cpp file I'm using: https://gist.github.com/xaviergodart/66e3b7ac9483735bb8ec1bba82ec923b

I'm targeting VST 64bits. It works perfectly when using the Linux Makefile exporter. However, when using the Visual Studio 2015 exporter on Windows 7 64bits, I get the following error:

Error   C2668   '_InterlockedDecrement': ambiguous call to overloaded function (compiling source file ..\..\FaustPluginProcessor.cpp)   gainCtl c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory\juce_Atomic.h  260 

It seems that there is some sort of collision between Windows headers. I'm fairly new to cpp development, especially on Windows, and I can't figure out if the problem is coming from the faust generated file, JUCE, or my side.

I tried both 4.3.1 and the develop branch.

Here is the build log:

1>c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_Atomic.h(260): error C2668: '_InterlockedDecrement': ambiguous call to overloaded function (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(209): note: could be 'long _InterlockedDecrement(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8875): note: or       'unsigned __int64 `anonymous-namespace'::_InterlockedDecrement(volatile unsigned __int64 *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8864): note: or       'unsigned long `anonymous-namespace'::_InterlockedDecrement(volatile unsigned long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8855): note: or       'unsigned int `anonymous-namespace'::_InterlockedDecrement(volatile unsigned int *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(2706): note: or       '`anonymous-namespace'::LONG `anonymous-namespace'::_InterlockedDecrement(volatile `anonymous-namespace'::LONG *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_Atomic.h(260): note: while trying to match the argument list '(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_Atomic.h(259): note: while compiling class template member function 'int juce::WindowsInterlockedHelpersBase<Type,4>::dec(volatile Type *) noexcept'
1>          with
1>          [
1>              Type=int
1>          ] (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_Atomic.h(381): note: see reference to function template instantiation 'int juce::WindowsInterlockedHelpersBase<Type,4>::dec(volatile Type *) noexcept' being compiled
1>          with
1>          [
1>              Type=int
1>          ] (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_Atomic.h(305): note: see reference to class template instantiation 'juce::WindowsInterlockedHelpersBase<Type,4>' being compiled
1>          with
1>          [
1>              Type=int
1>          ] (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_Atomic.h(322): note: see reference to class template instantiation 'juce::WindowsInterlockedHelpers<Type>' being compiled
1>          with
1>          [
1>              Type=int
1>          ] (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_Atomic.h(317): note: while compiling class template member function 'int juce::Atomic<int>::get(void) noexcept const' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_ReferenceCountedObject.h(103): note: see reference to function template instantiation 'int juce::Atomic<int>::get(void) noexcept const' being compiled (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_LeakedObjectDetector.h(101): note: see reference to class template instantiation 'juce::Atomic<int>' being compiled (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_LeakedObjectDetector.h(88): note: see reference to class template instantiation 'juce::LeakedObjectDetector<OwnerClass>::LeakCounter' being compiled (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  c:\users\xavier\documents\juce\juce-grapefruit-windows\juce\modules\juce_core\memory/juce_LeakedObjectDetector.h(114): note: see reference to class template instantiation 'juce::LeakedObjectDetector<OwnerClass>' being compiled (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  juce_osc.cpp
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thank you very much for your help.

hogliux commented 7 years ago

I think the problem is that you are including omp.h first and then the JuceLibraryHeader.h. Try swapping the order of these includes.

xaviergodart commented 7 years ago

Thanks for your help! I just tried swapping these inclusions and I still get the same error.

hogliux commented 7 years ago

Something must be including winbase.h before you include the JUCE headers. JUCE doesn't include winbase.h when you compile FaustPluginProcessor.cpp

sletz commented 7 years ago

Why do you have this omp.h in the first place ? It seem you're are using faust2juce with the -omp flag ? They without this for now.

xaviergodart commented 7 years ago

You're right, I was using the -omp flag to test out if it has a performance impact. Anyway, I just removed it and I still have this error.

Here is the updated cpp file: https://gist.github.com/xaviergodart/66e3b7ac9483735bb8ec1bba82ec923b

sletz commented 7 years ago

So it seem problems come because of "windows.h" inclusion : try to comment them and possibly the code that depends of them, just to check this hypothesis.

xaviergodart commented 7 years ago

I commented the 2 "windows.h" inclusions (line 1146 and 7581) and slightly rewrote the "GetCurrentTimeInUsec" (l. 1147) to get it compile. I don't have the error anymore, and the compilation succeeded. So the problem comes from the "windows.h" inclusion.

Cubase doesn't seems to recognize the generated vst, but that's another thing.

sletz commented 7 years ago

Thanks for reporting. Another commit on master-dev to conditionally include "windows.h" , assuming that when compiled with JUCE, JuceLibraryHeader.h will already have done that. Can you possibly test again and report?

And of course I'm interested by your "Cubase in VST" tests : what happens with other JUCE example demos ? Do they work? Could it be a 32/64 bits issue?

xaviergodart commented 7 years ago

Just tested again with the last master-dev. I have these errors:

1>..\..\FaustPluginProcessor.cpp(1151): error C2065: 'LARGE_INTEGER': undeclared identifier
1>..\..\FaustPluginProcessor.cpp(1151): error C2146: syntax error: missing ';' before identifier 'time'
1>..\..\FaustPluginProcessor.cpp(1151): error C2065: 'time': undeclared identifier
1>..\..\FaustPluginProcessor.cpp(1152): error C2065: 'LARGE_INTEGER': undeclared identifier
1>..\..\FaustPluginProcessor.cpp(1152): error C2146: syntax error: missing ';' before identifier 'frequency'
1>..\..\FaustPluginProcessor.cpp(1152): error C2065: 'frequency': undeclared identifier
1>..\..\FaustPluginProcessor.cpp(1153): error C2065: 'frequency': undeclared identifier
1>..\..\FaustPluginProcessor.cpp(1153): error C3861: 'QueryPerformanceFrequency': identifier not found
1>..\..\FaustPluginProcessor.cpp(1154): error C2065: 'time': undeclared identifier
1>..\..\FaustPluginProcessor.cpp(1154): error C3861: 'QueryPerformanceCounter': identifier not found
1>..\..\FaustPluginProcessor.cpp(1155): error C2065: 'time': undeclared identifier
1>..\..\FaustPluginProcessor.cpp(1155): error C2228: left of '.QuadPart' must have class/struct/union
1>  ..\..\FaustPluginProcessor.cpp(1155): note: type is 'unknown-type'
1>..\..\FaustPluginProcessor.cpp(1155): error C2065: 'frequency': undeclared identifier

It seems that JUCE only includes "winbase.h" and not "windows.h". Tricky...

sletz commented 7 years ago

so Fabian (https://github.com/hogliux) : we have headers files that #include at some places to support multi-platform deployment. Those files are then finally included in the generated FaustPluginProcessor.cpp which is itself started with the a global #include . This cause conflicts : in the JUCE context, what is the recommended way to deal with code that has multi-platforms parts? What is the the recommended way to deal with this issue?

sletz commented 7 years ago

Another try (following an advice given on #juce IRC...) : https://github.com/grame-cncm/faust/commit/052dc440417988e4900adc299e045ac02e4570d4

Can you test and report ?

hogliux commented 7 years ago

Can you try #define JUCE_CORE_INCLUDE_NATIVE_HEADERS=1 before including JuceLibraryHeader.h? This should include the windows headers for you.

sletz commented 7 years ago

Well : 1) we want to keep our multi-platform headers the way they are (that is they do #include when needed when used in a non JUCE context) 2) on #juce IRC someone told me that #include have to be done before JuceLibraryHeader.h, so I tried to restructure the FaustPluginProcessor.cpp file this way 3) and I'm waiting for xaviergodart to report if this works

xaviergodart commented 7 years ago

Tried the last master-dev. I have 5 "_Interlocked*" error. Here is the output log:

1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(82): error C2668: '_InterlockedCompareExchange': ambiguous call to overloaded function (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(179): note: could be 'long _InterlockedCompareExchange(volatile long *,long,long)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(9010): note: or       'unsigned __int64 `anonymous-namespace'::_InterlockedCompareExchange(volatile unsigned __int64 *,unsigned __int64,unsigned __int64)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8997): note: or       'unsigned long `anonymous-namespace'::_InterlockedCompareExchange(volatile unsigned long *,unsigned long,unsigned long)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8986): note: or       'unsigned int `anonymous-namespace'::_InterlockedCompareExchange(volatile unsigned int *,unsigned int,unsigned int)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(2738): note: or       '`anonymous-namespace'::LONG `anonymous-namespace'::_InterlockedCompareExchange(volatile `anonymous-namespace'::LONG *,`anonymous-namespace'::LONG,`anonymous-namespace'::LONG)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(82): note: while trying to match the argument list '(volatile long *, std::_Atomic_integral_t, std::_Atomic_integral_t)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(100): error C2668: '_InterlockedIncrement': ambiguous call to overloaded function (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(259): note: could be 'long _InterlockedIncrement(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8844): note: or       'unsigned __int64 `anonymous-namespace'::_InterlockedIncrement(volatile unsigned __int64 *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8833): note: or       'unsigned long `anonymous-namespace'::_InterlockedIncrement(volatile unsigned long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8824): note: or       'unsigned int `anonymous-namespace'::_InterlockedIncrement(volatile unsigned int *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(2701): note: or       '`anonymous-namespace'::LONG `anonymous-namespace'::_InterlockedIncrement(volatile `anonymous-namespace'::LONG *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(100): note: while trying to match the argument list '(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(105): error C2668: '_InterlockedIncrement': ambiguous call to overloaded function (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(259): note: could be 'long _InterlockedIncrement(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8844): note: or       'unsigned __int64 `anonymous-namespace'::_InterlockedIncrement(volatile unsigned __int64 *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8833): note: or       'unsigned long `anonymous-namespace'::_InterlockedIncrement(volatile unsigned long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8824): note: or       'unsigned int `anonymous-namespace'::_InterlockedIncrement(volatile unsigned int *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(2701): note: or       '`anonymous-namespace'::LONG `anonymous-namespace'::_InterlockedIncrement(volatile `anonymous-namespace'::LONG *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(105): note: while trying to match the argument list '(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(110): error C2668: '_InterlockedDecrement': ambiguous call to overloaded function (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(209): note: could be 'long _InterlockedDecrement(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8875): note: or       'unsigned __int64 `anonymous-namespace'::_InterlockedDecrement(volatile unsigned __int64 *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8864): note: or       'unsigned long `anonymous-namespace'::_InterlockedDecrement(volatile unsigned long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8855): note: or       'unsigned int `anonymous-namespace'::_InterlockedDecrement(volatile unsigned int *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(2706): note: or       '`anonymous-namespace'::LONG `anonymous-namespace'::_InterlockedDecrement(volatile `anonymous-namespace'::LONG *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(110): note: while trying to match the argument list '(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(119): error C2668: '_InterlockedDecrement': ambiguous call to overloaded function (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(209): note: could be 'long _InterlockedDecrement(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8875): note: or       'unsigned __int64 `anonymous-namespace'::_InterlockedDecrement(volatile unsigned __int64 *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8864): note: or       'unsigned long `anonymous-namespace'::_InterlockedDecrement(volatile unsigned long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(8855): note: or       'unsigned int `anonymous-namespace'::_InterlockedDecrement(volatile unsigned int *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(2706): note: or       '`anonymous-namespace'::LONG `anonymous-namespace'::_InterlockedDecrement(volatile `anonymous-namespace'::LONG *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(119): note: while trying to match the argument list '(volatile long *)' (compiling source file ..\..\FaustPluginProcessor.cpp)
sletz commented 7 years ago

Should be fixed in https://github.com/grame-cncm/faust/commit/10b37738706bccf603cdac2149a0403f05867774

Finally tested on VS 2013 in plugin and standalone modes.

xaviergodart commented 7 years ago

It worked! Compilation succeeded for both vst2 and vst3. I was able to open and use the plugins with VSTHost (http://www.hermannseib.com/english/vsthost.htm), but they didn't showed in Cubase 5. Will investigate.

Anyway, thanks a lot for your work!