On 09 Mar 2012, at 22:26, Mark Morgan Lloyd wrote:

> Thanks Jonas, I don't think I need to do it but I thought it was a fair 
> question: better safe than sorry.
> 
> OK, so hopefully I can get away with another. I'm looking at a program 
> written in Delphi, which reads a file containing the image of an IBM 
> mainframe tape. This has a record:
> 
> Type TAWSHeader=Record
>       ThisSize: Word;
> ..

If you want a record to have a predictable layout, always either
a) use {$packrecords c} if it's a translation of a C struct, or
b) declare it as "packed"

In other cases, you can (and will) have problems across different platforms or 
even compiler versions.

> but is there any way to define something like an endianness-correcting type, 
> i.e.:
> 
> Type TAWSHeader=Record
>       ThisSize: WordLE;
> ..
> 
> where by the time ThisSize is accessed any disparity has been corrected?

No.


Jonas_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to