On Fri, Oct 12, 2018 at 6:48 PM Sven Barth via fpc-devel <
fpc-devel@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 (
https://www.gtk.org/api/2.6/glib/glib-Basic-Types.html#gboolean)
where FALSE is 0 and TRUE is not FALSE.
https://www.gtk.org/api/2.6/glib/glib-Standard-Macros.html#TRUE:CAPS
so, it's more -1, rather than 1 and it doesn't quite maps to Boolean and/or
Boolean32. It's matches to LongBool.

var
  b : Boolean;
  lb : LongBool;
  b32 : Boolean32;
begin
  b := true;
  lb := true;
  b32 := true;
  writeln(byte(b),' ',LongWord(b32),' ',LongWord(lb));
  writeln(ord(b),' ',Ord(b32),' ',Ord(lb));
end.
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)

thanks,
Dmitry
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to