Strange stack variable corruption error after calling extern(C) function

cc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 15 23:18:43 PDT 2017


On Saturday, 15 April 2017 at 00:23:42 UTC, Lewis wrote:
> Holy crap, thank you. I know this is late, but I was playing 
> around with derelictFMOD, and ran into a strange crash like 
> yours on shutdown. Looking at the disassembly revealed that 
> FMOD_System_Close() was popping more off the stack as it 
> finished than I would have expected it to. I tried changing the 
> calling convention in derelictFMOD to extern(Windows) as 
> mentioned here, and that fixed the problem.
>
> I'll submit a pull request to that project to get that fixed. 
> But thank you both for having this forum discussion 11 months 
> prior that would eventually tip me in the direction of the 
> solution  :)

How did you get around the linker error?  I was never able to get 
this working, I tried

pragma(mangle, "FMOD_System_CreateSound")
extern(Windows) FMOD_RESULT FMOD_System_CreateSound               
(FMOD_SYSTEM *system, const char *name_or_data, FMOD_MODE mode, 
FMOD_CREATESOUNDEXINFO *exinfo, FMOD_SOUND **sound);

but it still prepends the underbar and fails to link with 
undefined symbol.


More information about the Digitalmars-d-learn mailing list