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

2017-04-16 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 16 April 2017 at 08:34:12 UTC, cc wrote: All this with extern(Windows) rather than extern(C) by the way. Why not use loadLibraryA ? then all the problems go away :) this is how derelict does it as well.

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

2017-04-16 Thread cc via Digitalmars-d-learn
All this with extern(Windows) rather than extern(C) by the way.

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

2017-04-16 Thread cc via Digitalmars-d-learn
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 t

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

2017-04-15 Thread cc via Digitalmars-d-learn
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

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

2017-04-14 Thread Lewis via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 19:06:30 UTC, cc wrote: I see, thanks. Double checking the original headers, I see the function is defined as: FMOD_RESULT F_API FMOD_System_CreateSound (FMOD_SYSTEM *system, const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, FMO

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

2016-05-05 Thread cc via Digitalmars-d-learn
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

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

2016-05-05 Thread Benjamin Thaut via Digitalmars-d-learn
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

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

2016-05-04 Thread cc via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 09:40:55 UTC, Benjamin Thaut wrote: On Tuesday, 3 May 2016 at 19:06:30 UTC, cc wrote: it fails to link with "Error 42: Symbol Undefined _FMOD_System_CreateSound@20". With extern(C) it compiles and runs but the problem from above persists. Is this on Windows x64?

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

2016-05-04 Thread Benjamin Thaut via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 19:06:30 UTC, cc wrote: it fails to link with "Error 42: Symbol Undefined _FMOD_System_CreateSound@20". With extern(C) it compiles and runs but the problem from above persists. Is this on Windows x64? Try replacing FMOD_RESULT by int. When declaring the fmod creat

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

2016-05-03 Thread cc via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 12:48:37 UTC, Benjamin Thaut wrote: It seems that one of the fmod functions you declared is not correct. Either the fmod api is not using the c calling convention or you made a mistake when declaring the paramters of the fmod functions. You should double check that the

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

2016-05-03 Thread Benjamin Thaut via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 11:32:31 UTC, cc wrote: Hello, I've been encountering a strange problem that seems to occur after calling some external C functions. I've been working on a program that incorporates the FMOD C API for playing sound, with a simple D binding based off the C headers, an