serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1714206 - /serf/trunk/serf_private.h
Date Fri, 13 Nov 2015 13:50:24 GMT
Author: rhuijben
Date: Fri Nov 13 13:50:24 2015
New Revision: 1714206

URL: http://svn.apache.org/viewvc?rev=1714206&view=rev
Log:
Make a standard 'bool' type available in our private API. This makes it easier
to make some variables self-documenting.

We already use a similar construct in the mock http server, so this just makes
it easier to use a bool in our private functions without inventing our own
boolean type.

I don't see how we can expose this in the public api in a fully compatible
way, but this at least allows using it internally.

* serf_private.h
  (bool,
   true,
   false): Define if not already defined.

Modified:
    serf/trunk/serf_private.h

Modified: serf/trunk/serf_private.h
URL: http://svn.apache.org/viewvc/serf/trunk/serf_private.h?rev=1714206&r1=1714205&r2=1714206&view=diff
==============================================================================
--- serf/trunk/serf_private.h (original)
+++ serf/trunk/serf_private.h Fri Nov 13 13:50:24 2015
@@ -21,6 +21,28 @@
 #ifndef _SERF_PRIVATE_H_
 #define _SERF_PRIVATE_H_
 
+#if !defined(HAVE_STDBOOL_H) && defined(_MSC_VER) && (_MSC_VER >= 1800)
+ /* VS 2015 errors out when redefining bool */
+#define HAVE_STDBOOL_H 1
+#endif
+
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#elif defined(__bool_true_false_are_defined) || defined(__cplusplus)
+/* Bool defined properly via C99 or C++ */
+#elif defined(bool)
+/* bool defined some other way (C99 compatible) */
+#else
+/* Do something C99 like ourself */
+#ifndef _Bool
+typedef int _Bool;
+#endif
+#define __bool_true_false_are_defined 1
+#define bool _Bool
+#define false 0
+#define true 1
+#endif
+
  /* Define a MAX macro if we don't already have one */
 #ifndef MAX
 #define MAX(a, b) ((a) < (b) ? (b) : (a))



Mime
View raw message