Why is the Objective-C Boolean data type defined as a signed char?
Posted
by EddieCatflap
on Stack Overflow
See other posts from Stack Overflow
or by EddieCatflap
Published on 2010-04-05T22:39:15Z
Indexed on
2010/04/05
22:43 UTC
Read the original article
Hit count: 217
Something that has piqued my interest is Objective-C's BOOL type definition.
Why is it defined as a signed char
(which could cause unexpected behaviour if a value greater than 1 byte in length is assigned to it) rather than as an int
, as C does (much less margin for error: a zero value is false, a non-zero value is true)?
The only reason I can think of is the Objective-C designers micro-optimising storage because the char
will use less memory than the int
. Please can someone enlighten me?
© Stack Overflow or respective owner