You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I misread the FFI manual, and mistakenly used the FFI boolean type to represent a C99 _Bool.
Since Chez Scheme predates C99 being common, boolean in the FFI actually just means int, which was what was commonly used before C99 _Bool. This means I was reading 3 bytes of garbage every time a C function returned a bool, causing things to evaluate to #t on the scheme side when they shouldn't.
Now that it's 2024 and C99 _Bool is pretty widely used, and C23 is even finally reserving the keyword bool for the type, so I think the FFI should add stdbool to explicitly represent this type on the Chez side. Currently, I have to assume that sizeof(bool)==1 on my platform, use unsigned-8, and do the zero-check myself. Although it's rare that someone would make their platform bools larger than 1 byte, hardcoding the size and having to do the check myself is still a minor annoyance.
The text was updated successfully, but these errors were encountered:
I misread the FFI manual, and mistakenly used the FFI
boolean
type to represent a C99_Bool
.Since Chez Scheme predates C99 being common,
boolean
in the FFI actually just meansint
, which was what was commonly used before C99_Bool
. This means I was reading 3 bytes of garbage every time a C function returned a bool, causing things to evaluate to #t on the scheme side when they shouldn't.Now that it's 2024 and C99 _Bool is pretty widely used, and C23 is even finally reserving the keyword
bool
for the type, so I think the FFI should addstdbool
to explicitly represent this type on the Chez side. Currently, I have to assume thatsizeof(bool)==1
on my platform, useunsigned-8
, and do the zero-check myself. Although it's rare that someone would make their platform bools larger than 1 byte, hardcoding the size and having to do the check myself is still a minor annoyance.The text was updated successfully, but these errors were encountered: