libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libcdio-devel] Removing homegrown bool in favor of stdbool


From: Rocky Bernstein
Subject: [Libcdio-devel] Removing homegrown bool in favor of stdbool
Date: Sun, 18 Aug 2019 18:27:19 -0400

Something I've wanted to do for a long time is remove the homegrown
definition of libcdio's bool type.

The Open Group Base Specifications Issue 6 of the IEEE Std 1003.1 2004
Edition has this listed. See
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html and
that says this is alinged with the ISO C standard.

15 years later I think it is pretty safe to assume that every system we
support now has <stdbool.h>. We dropped support for BSDI, and OS/2 a while
ago now.

The problem of our homegrown stdbool came up July a year ago in
https://lists.gnu.org/archive/html/libcdio-devel/2018-07/msg00043.html. I
am sorry this has taken a while to get around to, but better late than
never.

So unless there are objections, the next libcdio release will require a C
that has <stddbool.h>.

Right now I have committed this in branch stdbool-h. However the changes
were pretty small so here is a diff:

diff --git a/configure.ac b/configure.ac
index d57bdbec..8186827c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,7 +194,8 @@ AC_DEFINE(LIBCDIO_CONFIG_H, 1,
 dnl headers

 AC_HEADER_STDC
-AC_CHECK_HEADERS(alloca.h errno.h fcntl.h glob.h limits.h pwd.h stdbool.h)
+AC_CHECK_HEADERS(stdbool.h, [], [AC_MSG_ERROR(["Couldn't find or include
stdbool.h"])])
+AC_CHECK_HEADERS(alloca.h errno.h fcntl.h glob.h limits.h pwd.h)
 AC_CHECK_HEADERS(stdarg.h stdbool.h stdio.h sys/cdio.h sys/param.h \
  sys/time.h sys/timeb.h sys/utsname.h)
 AC_STRUCT_TIMEZONE
diff --git a/include/cdio/types.h b/include/cdio/types.h
index fd735786..dc0f90cf 100644
--- a/include/cdio/types.h
+++ b/include/cdio/types.h
@@ -27,6 +27,8 @@

 #ifdef __cplusplus
 extern "C" {
+#else
+# include <stdbool.h>
 #endif /* __cplusplus */

 /* If <sys/types.h> is not available on your platform please
@@ -103,27 +105,6 @@ typedef uint8_t ubyte;
 # endif
 #endif

-#ifndef __cplusplus
-
-/* All the stdbool.h seem to define those */
-#ifndef __bool_true_false_are_defined
-#define __bool_true_false_are_defined 1
-
-#undef bool
-#undef true
-#undef false
-
-#ifdef _Bool
-#define bool _Bool
-#else
-#define bool unsigned char
-#endif
-#define true 1
-#define false 0
-
-#endif /* __bool_true_false_are_defined */
-#endif /*C++*/
-
   /* some GCC optimizations -- gcc 2.5+ */

 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]