April 15, 2011 Re: Using D libs in C | ||||
---|---|---|---|---|
| ||||
All right, found something really odd today, might be a bug. If in C I have this: int16_t D_getPictureCoordX(int Pool, int Card); And in D I have this: short D_getPictureCoordX(int Pool, int Card); When I call D_getPictureCoord() from C, the parameters are all off, it seems that it receives either a random memory bit or the parameters are not in the same order as they should be. However, this only happens in Linux using 64-bit DMD, on Windows it works just fine. |
April 15, 2011 Re: Using D libs in C | ||||
---|---|---|---|---|
| ||||
AFAIK 'int' in D is always a 32-bit value. But in C, 'int' could be 64bit on 64bit platforms. You could try printing sizeof(int) in C and compare that to int.sizeof in D and see if they match. You probably know this, but make sure your exported D function is annotated with extern(C). |
April 15, 2011 Re: Using D libs in C | ||||
---|---|---|---|---|
| ||||
They both return 4, and both short and int16_t return 2. Also, I've noticed that if I use a struct (of four ints) instead, the same thing happens, the parameters are not correct. And yes, of course they are extern already. |
Copyright © 1999-2021 by the D Language Foundation