From: Daniel Jacobowitz <drow@mvista.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: gdb@sources.redhat.com
Subject: Re: Remove true/false from GDB ....
Date: Fri, 08 Feb 2002 15:37:00 -0000 [thread overview]
Message-ID: <20020208183719.A5159@nevyn.them.org> (raw)
In-Reply-To: <3C645FE0.30201@cygnus.com>
On Fri, Feb 08, 2002 at 06:31:44PM -0500, Andrew Cagney wrote:
> Hello,
>
> This is fallout from the recent <stdbool.h> problem.
>
> "bfd.h" was providing ``true'' and ``false'' as convenience
> enums/macros/... They unfortunatly clash with systems that provide
> <stdbool.h> (a header in c99?) and even some systems that don't. The
> relevant code block is:
>
> /* 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 ...
> ... many valiant attemts to define true and false ...
> #else
> /* Use enum names that will appear nowhere else. */
> typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
> #endif
>
> In short, bfd.h should never have been polluting the name space with
> ``true'' and ``false''.
>
> So the proposal is for "bfd.h" to remove all the above code and instead
> just define:
>
> typedef int bfd_boolean;
>
> i.e. 0 is false, non-zero is true, just like C intended :-)
>
> Problem is, some blocks of GDB make use of ``true'' and ``false'' and
> they will need to be changed. Two possabilities come to mind:
>
> #include "gdb_stdbool.h"
> which would wrap <stdbool.h>
>
> zap ``true'' and ``false''
>
> I've strong preferences for the latter. I think BFD serves as a very
> compelling example of what not to do :-)
>
> thoughts?
Strong preference for the latter here too. We should not attempt to
use true/false in C. You never know where they're going to come from -
or not come from.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
next prev parent reply other threads:[~2002-02-08 23:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-08 15:31 Andrew Cagney
2002-02-08 15:37 ` Daniel Jacobowitz [this message]
2002-02-08 15:55 ` Kevin Buettner
2002-02-08 22:03 ` Daniel Jacobowitz
2002-02-09 8:44 ` Andrew Cagney
2002-02-12 22:21 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020208183719.A5159@nevyn.them.org \
--to=drow@mvista.com \
--cc=ac131313@cygnus.com \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox