[Nagiosplug-devel] usage of the bool type
Andreas Ericsson
ae at op5.se
Tue Jun 5 11:13:00 CEST 2007
Matthias Eble wrote:
> Hi all,
>
> I was just wondering, why the bool type is never used in the plugin
> code. The only occurrence is in changes I made (two flags in
> check_disk). I've already heard, that int is actually faster to process
> despite the larger size, and that stdbool.h is not available on all
> platforms is that the reason?
>
int is always the fastest to process because it's defined to be the same
size as the registers on the CPU. bool is a C++-ism that got pulled into
C with C99. A C-program gains nothing, but loses portability by using bool
instead of int. Only if you compile a program with -Os (optimize for size,
not speed), will you stand a chance at losing performance by using bool
instead of int, as you can get several bool's contained in one int.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
More information about the Devel
mailing list