3 ms·
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 t
by marcosdumay 3y ago
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`.
- danobi 3y agoI think it has to keep it for externally visible functions, right?
- marcosdumay 3y agoYes, you are right. If you have to put a bool on the stack, it will have to keep the instructions.
- strkitten 3y agoDid you mean `typedef int bool`?
- deleted 3y ago[deleted]
- _kst_ 3y agoNo, _Bool is a distinct type, introduced by the 1999 edition of the standard.
- Longhanks 3y agoNo, 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.
- _kst_ 3y agoSorry, I managed to miss the context.
- _kst_ 3y agoC 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.
- kevin_thibedeau 3y agoMore significantly, true and false are now keywords.