TFBooleanType>>basicType should use uint8, not ushort - #16
Conversation
|
Confirmed on Mac too. |
|
real problem is: this depends largely on the library. |
|
Hi Esteban, Indeed, boolean is not a basic type in C, however we are not talking about C here. In fact, libraries we use are not implemented in C nor C++. Let's instead take Application binary interface as a foundation for describing FFI types. For example both Alien and Squeak FFI should respect x86_64 SysV ABI according to for example the following issue on OpenSmalltalk. SysV ABI is considered to be a de-facto standard when it comes to ABI, see a document here On page 14 of the above mentioned document you can find a table of types and their corresponding size and alignment: C99's definition of boolean as _Bool is taken as a foundation for describing boolean type. If for example SysV ABI and its boolean definition is not convincing enough we can look at another ABI specification, Itanium C++ ABI (also called Common Vendor ABI). In section 2.2 POD Data Types it defined a boolean as: where Enough about C 😃Let's talk Rust. Here is the official comment about
To conclude, the ideal solution would be to dispatch boolean size and alignment resolution through OSPlatform. Or agree that on all platforms supported by Pharo the size of bool is 1. |
|
This of course doesn't stop us from adding a bool16 type for any library that requires it. |
|
I like the fix right now, I would love to have an extension to choose the correct type in the library. I will open an issue for the future, but this fix is good enough right now. |
|
Thanks, Pablo! |

It looks like TFBooleanType is incorrectly defined:
TFBooleanType>>basicType
which is 16 bits, while booleans in C are 8 bits. (This caused one of our automated tests to fail. Interestingly, it only fails with the optimised version of the binary, the debug version passes).
Replacing it with:
TFBooleanType>>basicType
produces the correct behaviour.