I'm resuming this old thread because I need some other help
Well, I have converted a struct to pascal but I have some alignment problems. The original code is this:
Code:
typedef struct sTransferRegion {
  uint32 heartbeat;         
	int16 touchX,   touchY;   
	int16 touchXpx, touchYpx; 
	int16 touchZ1,  touchZ2;  
	uint16 tdiode1,  tdiode2; 
	uint32 temperature;       
	uint16 buttons;           
	union {
		uint8 curtime[8];       
    struct {
			u8 rtc_command;
			u8 rtc_year;          
			u8 rtc_month;         
			u8 rtc_day;           

			u8 rtc_incr;
			u8 rtc_hours;         
			u8 rtc_minutes;       
			u8 rtc_seconds;       
    };
  };
	uint16 battery;           
	uint16 aux;               
	pTransferSound soundData;
  vuint32 mailAddr;
  vuint32 mailData;
  vuint8 mailRead;
  vuint8 mailBusy;
  vuint32 mailSize;
} TransferRegion, * pTransferRegion;
And this is my (bad) translation
[pascal] sTransferRegion = record
heartbeat: cuint32;
touchX, touchY: cint16;
touchXpx, touchYpx: cint16;
touchZ1, touchZ2: cint16;
tdiode1, tdiode2: cuint16;
temperature: cuint32;
buttons: cuint16;
union: record
case integer of
0: (curtime: array [0..7] of cuint;
1: (
rtc_command: cuint8;
rtc_year: cuint8;
rtc_month: cuint8;
rtc_day: cuint8;
rtc_incr: cuint8;
rtc_hours: cuint8;
rtc_minutes: cuint8;
rtc_seconds: cuint8;
);
end;
battery: cuint16;
aux: cuint16;
soundData: pTransferSound;
mailAddr: cuint32;
mailData: cuint32;
mailRead: cuint8;
mailBusy: cuint8;
mailSize: cuint32;
end;
TransferRegion = sTransferRegion;
pTransferRegion = ^sTransferRegion;
[/pascal]


I think that the problem is in the union part... the nested record I have used is an ugly trick to avoid the limitation that forces to put variant parts as the last field in a record.
Any better solution? :scratch: