[fpc-pascal] Converting C's bit field struct
JeLlyFish.software at gmx.net
Wed Aug 13 23:36:19 CEST 2008
-------- Original-Nachricht --------
> Datum: Wed, 13 Aug 2008 22:03:23 +0100
> Von: Jonas Maebe <jonas.maebe at elis.ugent.be>
> An: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Betreff: Re: [fpc-pascal] Converting C\'s bit field struct
> On 13 Aug 2008, at 11:59, Vinzent Höfler wrote:
> > Should be something like that:
> > type
> > Unsigned_7 = 0 .. (1 shl 7) - 1;
> > Unsigned_20 = 0 .. (1 shl 20) - 1;
> > type
> > page_t = bitpacked record
> Yes and no: the layout of bitpacked records is by no means guaranteed
> to be the same as that of a C record, regardless of the definition of
> the C record.
Well, this is obviously a hardware structure and the actual layout should be checked regardless of the definition in C (IIRC, the C-standard doesn't guarantee any particular layout on such records neither).
> The internal format of bitpacked records is opaque and
> must not be used in any case where data has to be interchanged or
> where a particular layout is desired.
There was a reason why I brought up the portability issue. Honestly, what do you propose to mimic such stuff? I remember, we already had a discussion about that a couple of months ago. ;)
I don't want to bring up Ada again, but ... some years ago I implemented such nasty stuff for an embedded system. You might take a look for the implementation of system structures in that language http://www.gmx.de/mc/h9DZhQD3l4X4hfKafRIagg6e3PI6TW . Well, apart from Endianess issues, successful compilation virtually guarantees the layout.
I hope the link works, currently I don't own any web-space... Just click on that "GMX MediaCenter starten" button...
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx
More information about the fpc-pascal