[fpc-devel] Freepascal in microcontrollers
Daniël Mantione
daniel.mantione at freepascal.org
Thu Feb 28 09:12:52 CET 2008
Op Thu, 28 Feb 2008, schreef Michael Schnell:
>
>> To my knowledge there is no problem with the current implementation. Endian
>> conversion is already the reponsibility of the programmer. Therefore I
>> don't see a need for changes on the compiler side.
>>
> I don't understand your meaning here.
>
> If a record with binary fields is defined and transferred to (e.g.) another
> instance of the same program running on another machine by network or within
> a file, or if it needs to be crafted according to a specification of a
> network block or file format or a hardware device, endianess needs to be
> taken care of, and it's not nice if the user needs to write active code to do
> this, if a "bitpacked" type is available that seemingly can be used for that
> issue.
> You even might want to define a record that just holds a single 16 bit value.
> Here it would be good to be able do define endianess of the bitpacked
> structure to make it compatible with the communication partner.
Fixed endianness of records could be a language extension, it might even
ease programmers from doing endian conversion (rather than doing ifdefs,
just mention the endianness of your record), much nicer.
However, the situation as it is, is that we do not have such a language
feature and rely on manual endian conversion by means of ifdefs. There is
no difference between normal, packed, or bitpacked records, you have to
endian convert them manually.
Daniël
More information about the fpc-devel
mailing list