* Remove true/false from GDB ....
@ 2002-02-08 15:31 Andrew Cagney
2002-02-08 15:37 ` Daniel Jacobowitz
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andrew Cagney @ 2002-02-08 15:31 UTC (permalink / raw)
To: gdb
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?
I should also note that there is some urgency to this - BFD needs to be
fixed quickly - preferably before 5.2 of GDB branches.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Remove true/false from GDB ....
2002-02-08 15:31 Remove true/false from GDB Andrew Cagney
@ 2002-02-08 15:37 ` Daniel Jacobowitz
2002-02-08 15:55 ` Kevin Buettner
2002-02-12 22:21 ` Andrew Cagney
2 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2002-02-08 15:37 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb
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
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Remove true/false from GDB ....
2002-02-08 15:31 Remove true/false from GDB Andrew Cagney
2002-02-08 15:37 ` Daniel Jacobowitz
@ 2002-02-08 15:55 ` Kevin Buettner
2002-02-08 22:03 ` Daniel Jacobowitz
2002-02-12 22:21 ` Andrew Cagney
2 siblings, 1 reply; 6+ messages in thread
From: Kevin Buettner @ 2002-02-08 15:55 UTC (permalink / raw)
To: Andrew Cagney, gdb
On Feb 8, 6:31pm, Andrew Cagney wrote:
> 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?
If GDB made widespread use of ``true'' and ``false'', I'd suggest
converting these occurences to ``gdb_true'' and ``gdb_false''. I've
just looked though and GDB has surprisingly few uses of ``true'' and
``false''. That being the case, I like Andrew's latter suggestion of
just zapping them.
Here's the results of my search after removing the occurrences of
lines containing true and false in comments:
./memattr.c[34]: false, /* hwbreak */
./memattr.c[35]: false, /* cache */
./memattr.c[36]: false /* verify */
./memattr.c[185]: attrib.hwbreak = true;
./memattr.c[187]: attrib.hwbreak = false;
./memattr.c[191]: attrib.cache = true;
./memattr.c[193]: attrib.cache = false;
./memattr.c[197]: attrib.verify = true;
./memattr.c[199]: attrib.verify = false;
./corelow.c[172]: return (true);
./corelow.c[175]: return (false);
./irix5-nat.c[437]: abfd->cacheable = true;
./osfsolib.c[256]: abfd->cacheable = true;
./solib.c[240]: abfd->cacheable = true;
./symfile.c[1097]: sym_bfd->cacheable = true;
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Remove true/false from GDB ....
2002-02-08 15:55 ` Kevin Buettner
@ 2002-02-08 22:03 ` Daniel Jacobowitz
2002-02-09 8:44 ` Andrew Cagney
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2002-02-08 22:03 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Andrew Cagney, gdb
On Fri, Feb 08, 2002 at 04:54:41PM -0700, Kevin Buettner wrote:
> On Feb 8, 6:31pm, Andrew Cagney wrote:
>
> > 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?
>
> If GDB made widespread use of ``true'' and ``false'', I'd suggest
> converting these occurences to ``gdb_true'' and ``gdb_false''. I've
> just looked though and GDB has surprisingly few uses of ``true'' and
> ``false''. That being the case, I like Andrew's latter suggestion of
> just zapping them.
>
> Here's the results of my search after removing the occurrences of
> lines containing true and false in comments:
>
> ./memattr.c[34]: false, /* hwbreak */
> ./memattr.c[35]: false, /* cache */
> ./memattr.c[36]: false /* verify */
> ./memattr.c[185]: attrib.hwbreak = true;
> ./memattr.c[187]: attrib.hwbreak = false;
> ./memattr.c[191]: attrib.cache = true;
> ./memattr.c[193]: attrib.cache = false;
> ./memattr.c[197]: attrib.verify = true;
> ./memattr.c[199]: attrib.verify = false;
> ./corelow.c[172]: return (true);
> ./corelow.c[175]: return (false);
> ./irix5-nat.c[437]: abfd->cacheable = true;
> ./osfsolib.c[256]: abfd->cacheable = true;
> ./solib.c[240]: abfd->cacheable = true;
> ./symfile.c[1097]: sym_bfd->cacheable = true;
So would anyone object if we simply removed all of those?
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Remove true/false from GDB ....
2002-02-08 22:03 ` Daniel Jacobowitz
@ 2002-02-09 8:44 ` Andrew Cagney
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2002-02-09 8:44 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Kevin Buettner, gdb
>
> So would anyone object if we simply removed all of those?
There is something of a policy decision here. What happens when someone
submits new code using stdbool.h and ``true'' and ``false''? Is it
rejected outright (....), or as happens now, suggest this may not be
such a good idea after all.
I guess all that can be done is for the rationale to be clearly documented.
TRUE / FALSE probably fall into the same category.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Remove true/false from GDB ....
2002-02-08 15:31 Remove true/false from GDB Andrew Cagney
2002-02-08 15:37 ` Daniel Jacobowitz
2002-02-08 15:55 ` Kevin Buettner
@ 2002-02-12 22:21 ` Andrew Cagney
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2002-02-12 22:21 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb
Since there has been no assending view, I'll create a bug report. (my
todo list is currently overflowing :-()
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-02-13 6:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-08 15:31 Remove true/false from GDB Andrew Cagney
2002-02-08 15:37 ` Daniel Jacobowitz
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox