[fpc-devel] Freepascal in microcontrollers

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Feb 27 14:07:51 CET 2008


On 27 Feb 2008, at 13:55, Vinzent Hoefler wrote:

> On Wednesday 27 February 2008 12:21, Daniƫl Mantione wrote:
>>
>
>> I.e. we can
>> exchange packed records with TP/Delphi, what would be the problem
>> with bitpacking? If I recall well, Jonas made our bitpacking
>> compatible with GCC and GNU-Pascal.
>
> Great. And surely the PCI-board registers are compatible with GCC (oh,
> and if so, which compiler version then?).

C bitpacking is not "GCC-compatible" or not. C bitpacking is defined  
in the ABI for each platform (apart from the  
__attribute__((__packed__)) case, where the packing /is/ GCC-specific).

And yes, that means it's unsuited for hardware interfacing. You can  
hack around it (I repeat, this is a hack) by
a) using cases which are equal on all current ABIs (although this is  
not guaranteed to remain so by anyone in any way) like a.o. not using  
bitfields which span a byte/word/dword boundary (depending on the size  
of the bitfield and the bitfields coming before it)
b) taking into account the endianess of the host platform (since  
bitfields start counting from the most significant bit of big endian  
systems and from the least significant bit on little endian systems).


Jonas


More information about the fpc-devel mailing list