[fpc-pascal] How to translate this C header struct to Pascal

ik idokan at gmail.com
Fri Oct 23 20:39:17 CEST 2009


You can use bitpacked records:

http://www.google.com/codesearch?hl=en&lr=&q=bitpacked+record+package%3Ahttp%3A%2F%2Fpasxlibbind
\.googlecode\.com&sbtn=Search

Here is an example on how I use it :)

Ido
http://ik.homelinux.org/


On Fri, Oct 23, 2009 at 8:15 PM, Graeme Geldenhuys
<graemeg.lists at gmail.com>wrote:

> Hi,
>
> The first item is 31bit and the second item is 1 bit. Does FPC support
> a record structure that can define bit level sizes?
>
>
>    uint32_t    SearchStart:31;    // file offset to full text search table
>    uint32_t    searchlen:1;          // if high bit set, size of
> search record size is 16-bit
>
> If not, I guess I can continue with what I already do -  read this as
> a 32bit unsigned and then when I need to work with that data, split
> the 32bit value into two separate variables as shown below.
>
> var
>  SearchTableOffset: longint;
>  SearchTableRecordLengthIs16Bit: boolean;
> begin
>  SearchTableOffset := _pHeader^.SearchStart and $7fffffff;
>  SearchTableRecordLengthIs16Bit := _pHeader^.SearchStart and $80000000 > 0;
>
>
> Is there any better way of doing this?  Does Object Pascal record
> structure support bit size definitions?
>
>
> --
> Regards,
>  - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20091023/88dd2348/attachment.html>


More information about the fpc-pascal mailing list