Which value is better to use? Boolean true or Integer 1?
The above topic made me do some experiments with bool
and in
With GCC 4.5 on Linux and Windows at least, sizeof(bool) == 1
. On x86 and x86_64, you can't pass in less than an general purpose register's worth to a function (whether via the stack or a register depending on the calling convention etc...).
So the code for bool, when un-optimized, actually goes to some length to extract that bool value from the argument stack (using another stack slot to save that byte). It's more complicated than just pulling a native register-sized variable.