[Nagiosplug-devel] usage of the bool type

Holger Weiss holger at CIS.FU-Berlin.DE
Sun Jun 3 20:01:16 CEST 2007


* Matthias Eble <matthias.eble at mailing.kaufland-informationssysteme.com> [2007-06-02 14:10]:
> I was just wondering, why the bool type is never used in the plugin
> code.

The "bool" type was introduced with C99, so it doesn't (necessarily)
exist on older platforms.

> The only occurrence is in changes I made (two flags in check_disk).

I don't really care whether or not we use the "bool" type, but IMO we
should either use it everywhere or nowhere for consistency.  If we use
it, we must check for the existence of <stdbool.h> via Autoconf (which
we do already) and make sure to #include code such as the following in
every file which uses "bool", "true" or "false" (see gl/stdbool_.h):

--------------- 8< --------------------
#if HAVE_STDBOOL_H
#include <stdbool.h>
#else
#if !HAVE__BOOL
#ifdef __cplusplus
typedef bool _Bool;
#else
typedef unsigned char _Bool;
#endif	/* __cplusplus */
#endif	/* not HAVE__BOOL */
#define bool _Bool
#define false 0
#define true 1
#define __bool_true_false_are_defined 1
#endif	/* HAVE_STDBOOL_H */
--------------- 8< --------------------

Holger

-- 
PGP fingerprint:  F1F0 9071 8084 A426 DD59  9839 59D3 F3A1 B8B5 D3DE




More information about the Devel mailing list