[fpc-pascal] does the following translation of a c struct to FPC is correct ?
ik
idokan at gmail.com
Sun Feb 26 13:54:51 CET 2012
Hello,
I translated the following struct
struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined (__BIG_ENDIAN_BITFIELD)
__u8 version:4,
ihl:4;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__u8 tos;
__be16 tot_len;
__be16 id;
__be16 frag_off;
__u8 ttl;
__u8 protocol;
__sum16 check;
__be32 saddr;
__be32 daddr;
/*The options start here. */
};
to the following Pascal record:
iphdr = record
{$IFDEF ENDIAN_LITTLE}
jhl : Cardinal; // __u8 ihl:4,
version : Cardinal; // version:4
{$ELSE}
version : Cardinal; // __u8 version:4,
jhl : Cardinal; // version:4
{$ENDIF}
tos : cuint8;
tot_len : cint16;
id : cint16;
frag_off : cint16;
ttl : cint8;
protocol : cint8;
check : cuint16;
saddr : cint32;
daddr : cint32;
end;
The problem is, that I get weird data in the fields, so I think I did
not translate it properly, but can't figure out what have I missed.
Thanks,
Ido
More information about the fpc-pascal
mailing list