# VST2 plugins: function type mismatch

**URL:** <https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252>\
**Category:** Development\
**Created:** [November 15, 2024, 4:23pm UTC](https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252 "2024-11-15T16:23:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@martijn](https://forum.juce.com/u/martijn)\
**Post date:** [November 15, 2024, 4:23pm UTC](https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252/1 "2024-11-15T16:23:17Z")

</div>

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:

```auto
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`.

---

<div class="post-metadata">

**Author:** ![PeterRoos](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PeterRoos](https://forum.juce.com/u/PeterRoos)\
**Post date:** [November 15, 2024, 5:12pm UTC](https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252/2 "2024-11-15T17:12:30Z")

</div>

Why bother with the VST2 format? The SDK was deprecated in 2018, and you are no longer allowed to use it for new releases. The end of VST2 was announced in 2013.

---

<div class="post-metadata">

**Author:** ![martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@martijn](https://forum.juce.com/u/martijn)\
**Post date:** [November 21, 2024, 12:53pm UTC](https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252/3 "2024-11-21T12:53:41Z")

</div>

I’ve made a [pull request](https://github.com/juce-framework/JUCE/pull/1478) to fix the undefined behaviour.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [November 21, 2024, 9:44pm UTC](https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252/4 "2024-11-21T21:44:13Z")

</div>

Thanks for reporting this issue. We’ve pushed some patches to fix the problem:

> <https://github.com/juce-framework/JUCE/commit/73cb3b88adbce84abd30ed2bef765278241d2ca1>

> <https://github.com/juce-framework/JUCE/commit/6e910d801050e017a590a7ac2d0d2f3ea0bd187f>

---

<div class="post-metadata">

**Author:** ![stephenk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephenk/32/15198_2.png) [@stephenk](https://forum.juce.com/u/stephenk)\
**Post date:** [November 21, 2024, 11:06pm UTC](https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252/5 "2024-11-21T23:06:52Z")

</div>

> [@PeterRoos](#):
>
> Why bother with the VST2 format? The SDK was deprecated in 2018, and you are no longer allowed to use it for new releases. The end of VST2 was announced in 2013.

If he has a license for VST2, it’s still valid and he can still release products that support VST. It’s just the rest of us who came late that are, for the most part, not allowed to. 😢

A lot of people still use VST plugins that they own. I’d love to support it in the pluginhost type thing I’m developing, but I can’t (legally).

---

<div class="post-metadata">

**Author:** ![martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@martijn](https://forum.juce.com/u/martijn)\
**Post date:** [November 22, 2024, 8:01am UTC](https://forum.juce.com/t/vst2-plugins-function-type-mismatch/64252/6 "2024-11-22T08:01:09Z")

</div>

Thank you, reuk. That solves the issue for me with some bonus improvements on top!
