[fpc-pascal] header translation question: I need an int sized boolean

David W Noon david.w.noon at ntlworld.com
Sun Apr 22 14:02:43 CEST 2012


On Sun, 22 Apr 2012 01:54:17 +0200, Bernd wrote about [fpc-pascal]
header translation question: I need an int sized boolean:

>I have this from the GLIB heads:
>
>typedef int    gint;
>typedef gint   gboolean;
>
>Now I need a few packed records with such gboolean types in them. On
>my i386 I am now just using
>
>type
>  GBoolean = LongBool;
>
>Just to get something┬╣ up and running before the day was over.
>Unfortunately I cannot yet test this on 64 bit and I'm not a C
>programmer also. I assume on 64 bit architectures the int will be 64
>bit, is this correct?

No.

There should be one of two C macros defined by your 64-bit compiler:
__LP64__ or __LLP64__ . The first one implies that for 64 bits you use
"long int" and the second one implies that you use "long long int";
they also imply that all pointers are 64-bit.  Without any "long" prefix
an integer remains 32-bit.

GCC defines __LP64__ .  But an undecorated "int" declares a 32-bit
integer.

>I haven't found anything in the ctypes unit,
>should I use ifdefs to define my GBoolean or is there a more elegant
>one-liner to easily get such an integer sized bool?

Leave it as you currently have it.
-- 
Regards,

Dave  [RLU #314465]
=======================================================================
david.w.noon at ntlworld.com (David W Noon)
=======================================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20120422/7653fbfd/attachment.sig>


More information about the fpc-pascal mailing list