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

cc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 16 00:04:50 PDT 2017


Ok, I took another stab at this since I've had the problem 
sitting for however many months and I think I finally got it 
figured out.  I needed to reimport the import library from the 
DLL (via implib.exe) WITHOUT the /system switch, then, on 
inspecting it, it appears the correct function names to use are 
FMOD5_* rather than FMOD_*.

So,

FMOD_RESULT FMOD_System_CreateSound(FMOD_SYSTEM *system, const 
char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO 
*exinfo, FMOD_SOUND **sound);

becomes

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

or this would also work of course:

FMOD_RESULT FMOD5_System_CreateSound(FMOD_SYSTEM *system, const 
char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO 
*exinfo, FMOD_SOUND **sound);
alias FMOD5_System_CreateSound FMOD_System_CreateSound;

Now it finally links and the stack is no longer being corrupted!



More information about the Digitalmars-d-learn mailing list