Den 2011-04-11 09:19 skrev Alex Peshkoff såhär:
> I'm far not sure everything is so fine with that structure/class. Look here:
>      unsigned
> blrLength;
>
>      const unsigned char* blr;
> Pointer (8-bytes object) is placed after integer (4-bytes object). C
> language has a requirement to align it on 8-bytes boundary, but what
> about others? I't quite possible that some other language will try to
> save memory. The result is obvious - segfault when we use such structure.

1. This is a doc issue more than anything. There's always a workaround, 
e.g. insering dummy fields in a language that uses "packed" 
recs/structs. Just make sure you document the binary format complete 
with alignment/padding.

2. If I'm not mistaken most languages support a "packed" directive that 
tells the compiler to not align/pad the struct. Delphi does. But I doubt 
it's possible to do the other way around: tell a compiler to pad/align 
to N bytes. So, perhaps the most compatible way is to use packed structs 
everywhere. On the other hand, this will probably induce a performance 
hit - that's why alignment is used at all.

Kjell
-- 
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kj...@datadia.se
Telefon: 08-761 06 55
Mobil: 0733-44 24 64


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to