News for hackers. Stuff that matters.
Re:Truthiness in C by marcosdumay on Friday September 15, 2023 @12:35PM (#37525685)
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`.

Re:Truthiness in C by danobi on Friday September 15, 2023 @01:08PM (#37526169)
I think it has to keep it for externally visible functions, right?
Re:Truthiness in C by marcosdumay on Friday September 15, 2023 @01:38PM (#37526562)
Yes, you are right. If you have to put a bool on the stack, it will have to keep the instructions.
Re:Truthiness in C by strkitten on Friday September 15, 2023 @02:41PM (#37527463)
Did you mean `typedef int bool`?
Re:Truthiness in C by _kst_ on Friday September 15, 2023 @04:29PM (#37528723)
No, _Bool is a distinct type, introduced by the 1999 edition of the standard.
Re:Truthiness in C by Longhanks on Friday September 15, 2023 @04:55PM (#37529024)
No, marcosdumay wrote 'typedef bool int', by which he/she probably meant 'typedef int bool', which was not so uncommon when there was no native bool type in C, since the former would be illegal since the standard forbids typedefing already existent types such as int. strkitten informed about the probable typo.
Re:Truthiness in C by _kst_ on Friday September 15, 2023 @06:01PM (#37529623)
Sorry, I managed to miss the context.
Re:Truthiness in C by _kst_ on Friday September 15, 2023 @04:29PM (#37528720)
C has had _Bool natively since the 1999 ISO standard (24 years ago). The standard header <stdbool.h> 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.

Re:Truthiness in C by kevin_thibedeau on Friday September 15, 2023 @04:50PM (#37528957)
More significantly, true and false are now keywords.