[fpc-pascal] alignment of records
Xiangrong Fang
xrfang at gmail.com
Fri Aug 7 04:48:03 CEST 2015
Hi All,
I try to port a program from C to Pascal, see the following example:
#include <stdio.h>
#include <sys/socket.h>
#include <linux/if.h>
void main() {
printf("ifmap=%ld\n", sizeof(struct ifmap));
}
I converted it to:
est.c test.pas
X
program test;
{$mode objfpc}{$PACKRECORDS C}
type
ifmap = record
mem_start: dword;
mem_end: dword;
base_addr: word;
irq: byte;
dma: byte;
port: byte;
end;
begin
WriteLn('ifmap=', SizeOf(ifmap));
end.
The C struct's size is 24, but pascal record is 16. The ifmap struct is
defined as:
struct ifmap {
unsigned long mem_start;
unsigned long mem_end;
unsigned short base_addr;
unsigned char irq;
unsigned char dma;
unsigned char port;
/* 3 bytes spare */
};
How can I instruct FPC to align records exactly same as GCC?
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150807/8370dc96/attachment.html>
More information about the fpc-pascal
mailing list