]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove use of stdbool.h in GDB sources.
authorJoel Brobecker <brobecker@adacore.com>
Mon, 2 Mar 2015 14:01:23 +0000 (06:01 -0800)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 2 Mar 2015 14:02:11 +0000 (06:02 -0800)
Using type bool from stdbool unfortunately causes problems trying
to build GDB on AiX and Solaris:

    In file included from ../../src/gdb/utils.h:24:0,
                     from ../../src/gdb/defs.h:707,
                     from ../../src/gdb/utils.c:20:
    /[...]/curses.h:96:14: error: two or more data types in declaration
    specifiers
     typedef char bool;
                  ^
    make[2]: *** [utils.o] Error 1

In theory, the problem is in curses.h which, in both cases, do
something similar. On Solaris:

    #if !defined(__cplusplus) && !defined(_BOOL)
    typedef char bool;
    #endif /* !defined(__cplusplus) && !defined(_BOOL) */

On AiX:

    #if !defined(__cplusplus) || (defined(__IBMCPP__) &&(__IBMCPP__<400))
    #ifndef _BOOL
    #define _BOOL
    typedef int bool;
    #endif
    #endif

You can reproduce the same problem by trying to compile:

    % cat toto.c
    #include <stdbool.h>
    #include <curses.h>
    % gcc -c toto.c
    In file included from toto.c:1:0:
    /[...]/curses.h:159:13: error: two or more data types in declaration
    specifiers
     typedef int bool;
             ^

This specific issue wouldn't occur if we included curses.h before
including stdbool.h, and I looked at that just to be complete.
Here is a small schematic representation of the include logic:

  * utils.c:
      -> defs.h -> utils.h -> stdbool.h
      -> gdb_curses.h -> curses.h

Because defs.h should always be first on the list, it means that
stdbool.h will always necessarily be included ahead of curses.h.

But, thinking beyond this very specific issue, it shows that using
stdbool.h is going to cause problems on these systems until either
GCC fixes those includes in a way that makes them work; or we switch
to C++.

In the meantime, I think the path of least resistance is to revert
the use of stdbool.h, and use integers, the way we've done up until
now. The benefits of using type "bool" are modest, IMO, so not
a great loss, and a temporary one.

gdb/ChangeLog:

        * utils.h: Remove <stdbool.h> #include.
        (producer_is_gcc): Change return type to "int".
        * utils.c (producer_is_gcc): Change return type to int.
        Return 1 instead of true, and 0 instead of false.
        Adjust function documentation accordingly.

gdb/ChangeLog
gdb/utils.c
gdb/utils.h

index 232b90b8f99dbcfc2d313697b0ea91fa9b8de9c8..56e7206dd7b28dd1fc99de5e2903c216f3821d7e 100644 (file)
@@ -1,3 +1,11 @@
+2015-03-02  Joel Brobecker  <brobecker@adacore.com>
+
+       * utils.h: Remove <stdbool.h> #include.
+       (producer_is_gcc): Change return type to "int".
+       * utils.c (producer_is_gcc): Change return type to int.
+       Return 1 instead of true, and 0 instead of false.
+       Adjust function documentation accordingly.
+
 2015-03-02  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        * s390-linux-nat.c (have_regset_vxrs): New static variable.
index 3ce5814904b54ee4e27822b2e7ff917d200cbc56..4f9f4f05a2dd56e980d0ecddbe18e535282c7ba7 100644 (file)
@@ -3269,11 +3269,11 @@ producer_is_gcc_ge_4 (const char *producer)
   return minor;
 }
 
-/* Returns true if the given PRODUCER string is GCC and sets the MAJOR
-   and MINOR versions when not NULL.  Returns false if the given PRODUCER
+/* Returns nonzero if the given PRODUCER string is GCC and sets the MAJOR
+   and MINOR versions when not NULL.  Returns zero if the given PRODUCER
    is NULL or it isn't GCC.  */
 
-bool
+int
 producer_is_gcc (const char *producer, int *major, int *minor)
 {
   const char *cs;
@@ -3299,11 +3299,11 @@ producer_is_gcc (const char *producer, int *major, int *minor)
       if (*cs && isspace (*cs))
         cs++;
       if (sscanf (cs, "%d.%d", major, minor) == 2)
-       return true;
+       return 1;
     }
 
   /* Not recognized as GCC.  */
-  return false;
+  return 0;
 }
 
 /* Helper for make_cleanup_free_char_ptr_vec.  */
index d8afa794813aa4d9e46abf221e4755665d7336e5..b8e1aff76920aff284dfe83d0b862484b06c0cf2 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef UTILS_H
 #define UTILS_H
 
-#include <stdbool.h>
-
 #include "exceptions.h"
 
 extern void initialize_utils (void);
@@ -304,7 +302,7 @@ extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
 #endif
 
 extern int producer_is_gcc_ge_4 (const char *producer);
-extern bool producer_is_gcc (const char *producer, int *major, int *minor);
+extern int producer_is_gcc (const char *producer, int *major, int *minor);
 
 extern int myread (int, char *, int);