[fpc-pascal] Initializing constant (translate from C)

Dmitry Boyarintsev skalogryz.lists at gmail.com
Mon Oct 16 21:42:00 CEST 2017


On Mon, Oct 16, 2017 at 3:36 PM, Darius Blaszyk <dhkblaszyk at zeelandnet.nl>
wrote:

> Here's an interesting one. In C I have this code:
>
> #define ID1 MAKE_ID('A', 'B')
>
> Where MAKE_ID is a macro that depending on the endianness of the target
> will create either AB or BA.
>
> The only issue with the following approach
const
  ID  ={$IFDEF ENDIAN_LITTLE} 'AB' {$ELSE} 'BA' {$ENDIF};

is if MAKE_ID is used anywhere else, you'll have to repeat the code.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171016/3bd02287/attachment.html>


More information about the fpc-pascal mailing list