Yeah, C now has bool natively... I'm quite confident the compiler will optimize that test-and-move away as soon as you use the bool for something, giving you the same assembly as a last century's `typedef bool int`.
Truthiness in C
11–20 of 26 posts
Re: Truthiness in C
#12Re: Truthiness in C
#13If I'm not mistaken, the `(bool)` is unnecessary due to how implicit conversion works: `In a return statement, the value of the operand of return is converted to an object having the return type of the function` [1] ...unless I understood it incorrectly :/ [1] https://en.cppreference.com/w/c/language/conversion
Re: Truthiness in C
#14Re: Truthiness in C
#15Re: Truthiness in C
#16Re: Truthiness in C
#17Re: Truthiness in C
#18Yeah, C now has bool natively... I'm quite confident the compiler will optimize that test-and-move away as soon as you use the bool for something, giving you the same assembly as a last century's `typedef bool int`.
The upcoming C23 standard will define "bool" as a keyword.
Re: Truthiness in C
#19Yeah, C now has bool natively... I'm quite confident the compiler will optimize that test-and-move away as soon as you use the bool for something, giving you the same assembly as a last century's `typedef bool int`.
Did you mean `typedef int bool`?
Re: Truthiness in C
#20Yeah, C now has bool natively... I'm quite confident the compiler will optimize that test-and-move away as soon as you use the bool for something, giving you the same assembly as a last century's `typedef bool int`.
C has had _Bool natively since the 1999 ISO standard (24 years ago). The standard header has "#define bool _Bool". (The ugly name "_Bool" was chosen to avoid conflicting with existing code.) The upcoming C23 standard will define "bool" as a keyword.