[fpc-devel] OSX: Setting up parameters to objc_msgSend()

Dmitry Boyarintsev skalogryz.lists at gmail.com
Sat Oct 13 01:56:53 CEST 2018

On Fri, Oct 12, 2018 at 6:48 PM Sven Barth via fpc-devel <
fpc-devel at lists.freepascal.org> wrote:

> Not quite: the Boolean16, Boolean32 and Boolean64 types were introduced
> because the libraries provided by GTK required a 4-Byte boolean type that
> worked like Object Pascal's Boolean.
That's interesting.
Let me ask a couple of things here:

1) gboolean is a size of int (
where FALSE is 0 and TRUE is not FALSE.
so, it's more -1, rather than 1 and it doesn't quite maps to Boolean and/or
Boolean32. It's matches to LongBool.

  b : Boolean;
  lb : LongBool;
  b32 : Boolean32;
  b := true;
  lb := true;
  b32 := true;
  writeln(byte(b),' ',LongWord(b32),' ',LongWord(lb));
  writeln(ord(b),' ',Ord(b32),' ',Ord(lb));
Results in:
1 1 4294967295
1 1 -1
(matches documentation)

2) why the were they named booleanN rather than gtkboolean or something?
(I'm referring to the suggestion of using objcbool name. It seem to fit)

> Then maybe it's an issue about the ABI (maybe all values with a size < 4
> need to be correctly extended due to the ABI).

I think Jonas clearly stated that ABI call works properly (to the word of
the specification)
The issues is that BOOL in objective-C is for Intel (macOS) is not _Bool
but rather a signed char.

As of today, Pascal doesn't provide Boolean type that behaves like a signed
char in ABI terms.
(Boolean, and Boolean8 are size of _Bool which matched the size of signed
char, though treated are passed as "_Bool" following ABI rules)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20181012/cb79a779/attachment.html>

More information about the fpc-devel mailing list