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

cc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 5 23:32:53 PDT 2016


On Thursday, 5 May 2016 at 09:42:00 UTC, Benjamin Thaut wrote:
> On Wednesday, 4 May 2016 at 17:53:32 UTC, cc wrote:
>>
>> The OS is Win64 though the program is being compiled as 32-bit 
>> and I'm using the 32-bit distributed DLL.
>> fmod.dll: PE32 executable (DLL) (GUI) Intel 80386, for MS 
>> Windows
>>
>> Tried int and long as the return type, same issue both ways.  
>> Tried void too just in case, same thing though.
>
> Could you please post the definition of FMOD_RESULT. Its 
> possible that the create sound function returns it on stack and 
> not inside a register. This is usually the case if FMOD_RESULT 
> is defined as a struct in C/C++. But its hard to say. In your 
> case I would actually look at the disassembly and step through 
> it to see where its going wrong and messing up the stack.

In fmod_common.h:

typedef enum
{
     FMOD_OK,                        /* No errors. */
     FMOD_ERR_ALREADYLOCKED,         /* Tried to call lock a 
second time before unlock was called. */
     ...
     FMOD_RESULT_FORCEINT = 65536    /* Makes sure this enum is 
signed 32bit. */
} FMOD_RESULT;


In D I defined it as  enum FMOD_RESULT : int { ... }


More information about the Digitalmars-d-learn mailing list