`true' and `false'; Was: K&R patch for binutils bfd directory

Andrew Cagney ac131313@redhat.com
Fri Oct 25 07:32:00 GMT 2002


> Wasn't a BFD things-to-do-today thwack ``true'' and ``false''?  Someone is definitly ment to be removing them from bfd.h.

Just in case anyone needs a reminder as to why:

 From bfd/bfd-in2.h:

/* To squelch erroneous compiler warnings ("illegal pointer
    combination") from the SVR3 compiler, we would like to typedef
    boolean to int (it doesn't like functions which return boolean.
    Making sure they are never implicitly declared to return int
    doesn't seem to help).  But this file is not configured based on
    the host.  */
/* General rules: functions which are boolean return true on success
    and false on failure (unless they're a predicate).   -- bfd.doc */
/* I'm sure this is going to break something and someone is going to
    force me to change it.  */
/* typedef enum boolean {false, true} boolean; */
/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h>  -fnf */
/* It gets worse if the host also defines a true/false enum... -sts */
/* And even worse if your compiler has built-in boolean types... -law */
/* And even worse if your compiler provides a stdbool.h that conflicts
    with these definitions... gcc 2.95 and later do.  If so, it must
    be included first.  -drow */
#if defined (__GNUG__) && (__GNUC__ > 2 || (__GNUC__ == 2 && 
__GNUC_MINOR__ >= 6
))
#define TRUE_FALSE_ALREADY_DEFINED
#else
#if defined (__bool_true_false_are_defined)
/* We have <stdbool.h>.  */
#define TRUE_FALSE_ALREADY_DEFINED
#endif
#endif
#ifdef MPW
/* Pre-emptive strike - get the file with the enum.  */
#include <Types.h>
#define TRUE_FALSE_ALREADY_DEFINED
#endif /* MPW */
#ifndef TRUE_FALSE_ALREADY_DEFINED
typedef enum bfd_boolean {false, true} boolean;
#define BFD_TRUE_FALSE
#else
/* Use enum names that will appear nowhere else.  */
typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
#endif

gdb/utils.h:

/* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
    "defs.h" should be included first.  Unfortunatly some systems
    (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
    and they clash with "bfd.h"'s definiton of true/false.  The correct
    fix is to remove true/false from "bfd.h", however, until that
    happens, hack around it by including "config.h" and <curses.h>
    first.  */

If you look through the archives you'll see the consensus was to pull 
this bogosity.  Just waiting for someone with the cycles ....

Andrew




More information about the Binutils mailing list