Running our software with clang’s UBsan enabled I am running into errors caused by the callback functions having a different prototype in the host and the plugin. So far I’ve noticed this with the audioMaster and dispatcher callback.
In aeffect.h, provided by the VST SDK the prototypes are defined as follows:
typedef VstIntPtr(VSTCALLBACK* audioMasterCallback)(AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt);
typedef VstIntPtr(VSTCALLBACK* AEffectDispatcherProc)(AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt);
The callback implementation as provided by JUCE is in both modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp, where audioMaster is defined as follows:
static pointer_sized_int VSTCALLBACK audioMaster (Vst2::AEffect*, int32, int32, pointer_sized_int, void*, float);
and modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp, which defines dispatcherCB as follows:
static pointer_sized_int dispatcherCB (Vst2::AEffect* vstInterface, int32 opCode, int32 index,
pointer_sized_int value, void* ptr, float opt)`
If I change those definitions to use Vst2::VstIntPtr instead of pointer_sized_int the errors go away. Turns out that on my system, pointer_sized_int resolves to long long and Vst2::VstIntPtr resolves to long, which is a different type.
There’s probably other things that need to be changed to fix it completely on all platforms. It’s probably best to only use the typedefs as provided by the SDK for the plugins, and not those as defined in juce_MathsFunctions.h.