summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Arntsen <tor@spacetec.no>2010-05-31 14:08:35 +0200
committerYang Tse <yangsita@gmail.com>2010-05-31 14:08:35 +0200
commitcd59ae213f9adbe53e8cbade8e3159b56e618dc2 (patch)
tree48357224154e43d2e0ae215efe35c4992d0f4c00
parentbe68a8ed0dbd49bc9402bd6247448cab455ede15 (diff)
downloadc-ares-cd59ae213f9adbe53e8cbade8e3159b56e618dc2.tar.gz
c-ares-cd59ae213f9adbe53e8cbade8e3159b56e618dc2.tar.bz2
c-ares-cd59ae213f9adbe53e8cbade8e3159b56e618dc2.zip
improve alternative definition of bool to use enum instead of unsigned char
-rw-r--r--setup_once.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/setup_once.h b/setup_once.h
index b99d7e8..17ef226 100644
--- a/setup_once.h
+++ b/setup_once.h
@@ -254,24 +254,42 @@ struct timeval {
/*
- * Typedef to 'unsigned char' if bool is not an available 'typedefed' type.
+ * 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
+ * On non-C99 platforms there's no bool, so define an enum for that.
+ * On C99 platforms 'false' and 'true' also exist. Enum uses a
+ * global namespace though, so use bool_false and bool_true.
*/
#ifndef HAVE_BOOL_T
-typedef unsigned char bool;
-#define HAVE_BOOL_T
+ typedef enum {
+ bool_false = 0,
+ bool_true = 1
+ } bool;
+
+/*
+ * Use a define to let 'true' and 'false' use those enums. There
+ * are currently no use of true and false in libcurl proper, but
+ * there are some in the examples. This will cater for any later
+ * code happening to use true and false.
+ */
+# define false bool_false
+# define true bool_true
+# define HAVE_BOOL_T
#endif
/*
- * Default definition of uppercase TRUE and FALSE.
+ * Redefine TRUE and FALSE too, to catch current use. With this
+ * change, 'bool found = 1' will give a warning on MIPSPro, but
+ * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro,
+ * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too.
*/
#ifndef TRUE
-#define TRUE 1
+#define TRUE true
#endif
#ifndef FALSE
-#define FALSE 0
+#define FALSE false
#endif