[fpc-pascal] struct definition in C

Darius Blaszyk dhkblaszyk at zeelandnet.nl
Sun Mar 23 20:34:48 CET 2014


 

Thanks Jonas!
One more question. Why is it that there is no portable way to access the
bitfields? Is that because of endian issues, or is there more to it?
What about declaring the bitfields in a bitpacked record as "array of
boolean"? 

Regards, Darius 

Jonas Maebe schreef op 23 mrt '14: 

> On 23/03/14 19:39, Darius Blaszyk wrote:
> 
>> What would be the equivalent of the following struct definition in C? typedef struct MyStruct { unsigned a :6; unsigned b :15; unsigned c:11; }MyStruct; I imagine this is some sort of struct initialization. Is thi spossible in FPC as well, or what is the best alternative?
> 
> It's not an initialization, it's a struct with bitfields. FPC currently 
> does not support C-compatible bitfield packing. To get a record with 
> equal alignment and size you can declare it as "record data: cuint; 
> end;", but there is currently no way in FPC to access the bitfields in a 
> portable way across platforms.
> 
> Jonas
> 
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal [1]
 

Links:
------
[1] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140323/d5977e5d/attachment.html>


More information about the fpc-pascal mailing list