Uhm... I don't know... sizeof gives 60 for c struct and 56 for pascal record :think:
sizeof the unpacked record in delphi is 60. What exactly is a vuintxx?
edit: a quick search tells me it means a volatile field? how could the end of a c struct be volatile?
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Really I don't care about volatile, because it is an optimization that fpc can't handle yet, so I simply ignore it.
Correction: the record size is 60 too... I forgot to remove a "packed" I have put to make a try ops:
BTW, the alignment problem remains
If you find out where in the struct the alignment differs then
you could make a packed record, and then inserting padding
bytes manually until it fits.
Like this:
[pascal]sTransferRegion = packed record
heartbeat: cuint32;
touchX, touchY: cint16;
touchXpx, touchYpx: cint16;
touchZ1, touchZ2: cint16;
tdiode1, tdiode2: cuint16;
pad1,pad2 : byte; //padding
buttons: cuint16;
pad3,pad4 : byte; //padding
...etc
[/pascal]
Also my first guess would be that the c/pascal alignment could
differ at the last 8-bit fields: mailRead, mailBusy: cuint8;
So, I resolved that alignment issue. To tell the truth it was the effect and not the cause... :roll:
Now I have another problem (I hope it will be the last one...). I have a function in a c library that requires as parameter a pointer to a void function:
I have translated it as:Code:typedef void (* VoidFunctionPointer)(void); void irqSet(IRQ_MASK irq, VoidFunctionPointer handler);
[pascal]procedure irqSet(irq: IRQ_MASK; handler: Pointer); cdecl; external;[/pascal]
and it works if I use it in this way:
[pascal]irqSet(IRQ_VBLANK, @myProcedure);[/pascal]
Now the problem comes if I try to pass to irqSet a void function that is implemented in another c library:
translated as:Code:extern void Wifi_Interrupt();
[pascal]procedure Wifi_Interrupt(); cdecl; external;[/pascal]
hangs on:
[pascal]irqSet(IRQ_WIFI, @Wifi_Interrupt);[/pascal] :scratch:
would this make any difference?
[pascal]type
VoidFunctionPointer = procedure; cdecl;[/pascal]
[pascal]procedure irqSet(irq: IRQ_MASK; handler: VoidFunctionPointer); cdecl; external;[/pascal]
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Bookmarks