From: Ian Lance Taylor <ian@airs.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: binutils@sources.redhat.com, gdb@sources.redhat.com
Subject: Re: enum { BFD_ENDIAN_BIG, ...}
Date: Sun, 16 Dec 2001 21:49:00 -0000 [thread overview]
Message-ID: <siheqq1jpg.fsf@daffy.airs.com> (raw)
In-Reply-To: <3C1D4919.1000102@cygnus.com>
Andrew Cagney <ac131313@cygnus.com> writes:
> I'm curious. Why/how did BFD_ENDIAN_BIG come to be first in the enum:
>
> enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
I just wrote it that way. Something had to be first.
> This has the (intended?) effect of memset(0) setting a value to
> BFD_ENDIAN_BIG where as code using the common host dependant
> BIG_ENDIAN / LITTLE_ENDIAN would have treated such a value as
> undefined.
I didn't anticipate that the enum would be used in a field which was
not initialized in a normal fashion. I personally pretty much never
privilege a particular element of an enum; either the enum matches an
external definition, in which case all elements have explicit values,
or the enum does not match an external definition, in which case none
of the elements have explicit values. I don't normally initialize
structures using memset(0); I normally explicitly initialize all
fields in one way or another.
> GDB, which is trying to eliminate its dependance on those host
> dependant macros is suffering minor heart burn as a result of the
> difference - it has been assuming that ZERO indicated an uninitialized
> (roughly BFD_ENDIAN_UNKNOWN) value.
It should not break BFD to change the order of the enum values. If it
does, I would consider that to be a bug. If you do change the order,
I would (obviously) recommend an explicit = 0, and a comment
indicating why BFD_ENDIAN_UNKNOWN has a zero value.
Ian
next prev parent reply other threads:[~2001-12-17 5:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-16 17:23 Andrew Cagney
2001-12-16 21:49 ` Ian Lance Taylor [this message]
2001-12-17 7:30 ` Andrew Cagney
2001-12-17 16:29 ` Alan Modra
2001-12-17 16:46 ` Richard Henderson
2001-12-17 17:44 ` Alan Modra
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=siheqq1jpg.fsf@daffy.airs.com \
--to=ian@airs.com \
--cc=ac131313@cygnus.com \
--cc=binutils@sources.redhat.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