C callbacks getting a value of 0! Bug in D?
Johnson Jones via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 28 18:34:40 PDT 2017
On Tuesday, 29 August 2017 at 00:42:45 UTC, Steven Schveighoffer
wrote:
> On 8/28/17 7:47 PM, Johnson Jones wrote:
>> [...]
>
> Then I think possibly the port audio bindings are not correct.
> It's also possible that long is not 64-bit even on the platform
> you are using. Finally, it's also possible that the D compiler
> is not generating the call correctly.
>
> When I test on my mac, c_long is 8-bytes. I'm not sure what it
> is in your case, try this code and see what happens:
>
> import core.stdc.config;
>
> pragma(msg, c_long.sizeof); // prints 8 on my box.
>
> And in c:
>
> #include <stdio.h>
>
> int main()
> {
> printf("%lu\n", sizeof(long)); // also prints 8 on my box
> return 0;
> }
>
> They should match. If they don't, that's a D bug (in either
> core.stdc.config or the compiler, I'm not sure which). If they
> do, then one of the other two possibilities is happening, and I
> would lean towards the bindings being incorrect.
>
> -Steve
import core.stdc.config;
pragma(msg, c_long.sizeof);
prints 4UL
both on x64 and x86
and and C:
void foo()
{
int dummy;
switch (dummy) {
case sizeof(long) :
case sizeof(long) :
break;
}
}
produces 4 on both x86 and x64. So, I'm not sure how you are
getting 8.
More information about the Digitalmars-d-learn
mailing list