Problem calling extern(C) function
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 15 09:54:51 PST 2014
On Monday, 15 December 2014 at 17:48:32 UTC, AuoroP via
Digitalmars-d-learn wrote:
> ulong jpegSize,
Without looking too closely, this sets off an alarm to me: C's
long and D's long are not really compatible because C's long has
variable size and D's long is 64 bit.
I'd say try "import core.stdc.config;" and replace all instances
of ulong with c_ulong and all instances of long with c_long when
interfacing with C.
> DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle handle,
> unsigned char *jpegBuf, unsigned long jpegSize, int *width, int
> *height,
yeah the D long is 32 bits longer than the C function expects, so
every argument after it is offset by that amount.
More information about the Digitalmars-d-learn
mailing list