[fpc-pascal] Translating c records
Michael Van Canneyt
michael at freepascal.org
Wed Apr 24 22:46:07 CEST 2019
On Wed, 24 Apr 2019, Rainer Stratmann wrote:
> struct sockaddr_ll {
> unsigned short sll_family;
> unsigned short sll_protocol;
> int sll_ifindex;
> unsigned short sll_hatype;
> unsigned char sll_pkttype;
> unsigned char sll_halen;
> unsigned char sll_addr[8];
> };
>
>
> type
> sockaddr_ll = record
> sll_family : word;
> sll_protocol : word;
> sll_ifindex : integer;
> sll_hatype : word;
> sll_pkttype : byte;
> sll_halen : byte;
> sll_addr: array[ 0 .. 7 ] of byte;
> end;
>
> Is this correct?
if you add
{$PPACKRECORDS C}
And make integer a longint (that is always 4 bytes, regardless of the mode
you're compiling in), then it should be OK.
You can always compare with
#include <stdio.h>
#include <yourcheader.h>
int main () {
printf("%d\n",sizeof(struct sockaddr_l));
}
and in pascal
writeln(sizeof(sockaddr_ll));
Michael.
More information about the fpc-pascal
mailing list