DerelictFmod should use extern(Windows) calling convention on windows
the-tallest-tower opened this issue · comments
In fmod_common.h, you'll see all the defines related to the API and calling conventions. On windows, we don't use cdecl, we use stdcall. So in DerelictFmod, we shouldn't use extern(C), but instead extern(Windows).
I had a nasty crash caused by this, where inspecting the disassembly revealed that FMOD_System_Close() was popping more off the stack than I was expecting it to if it were following cdecl. This tipped me off, and lead me to https://forum.dlang.org/post/jttxkcpehfinihjhmzvw@forum.dlang.org, where someone mentioned the possibility of FMOD not being built using cdecl. I tried changing the extern(C) in funcs.d to extern(Windows), and that fixed the problem.
Good catch! Care to create a Pull Request?
fixed in #3