From: Tom Tromey <tromey@redhat.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: grischka <grishka@gmx.de>, emacs-devel@gnu.org
Subject: Re: enum may be signed
Date: Mon, 03 May 2010 11:04:41 -0600 [thread overview]
Message-ID: <m3sk68syqe.fsf@fleche.redhat.com> (raw)
In-Reply-To: <jwvmxwjo6gr.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 01 May 2010 13:56:40 -0400")
>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
Stefan> Interesting. I didn't know about that part of the C language. Is it
Stefan> possible to specify that this is an unsigned enum somehow?
Stefan> I've tried "enum symbol_redirect redirect : 3;" but at least GCC didn't
Stefan> like it.
Stefan> Of course we can add one more bit (we have plenty of bits left there),
Stefan> but I'd first like to know how this is usually handled, since it seems
Stefan> to imply that MSVC always requires one extra bit to store enums.
GCC and GDB do something like this:
/* Be conservative and use enum bitfields only with GCC.
This is copied from gcc 3.3.1, system.h. */
#if defined(__GNUC__) && (__GNUC__ >= 2)
#define ENUM_BITFIELD(TYPE) enum TYPE
#else
#define ENUM_BITFIELD(TYPE) unsigned int
#endif
Used like:
struct main_type
{
/* Code for kind of type */
ENUM_BITFIELD(type_code) code : 8;
...
Continuing to use an enum bitfield on gcc is nice, because gcc will warn
if the enum is too large to fit in the bitfield.
Tom
prev parent reply other threads:[~2010-05-03 17:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-01 15:47 enum may be signed grischka
2010-05-01 17:56 ` Stefan Monnier
2010-05-01 18:37 ` Ken Raeburn
2010-05-01 18:51 ` grischka
2010-05-03 17:04 ` Tom Tromey [this message]
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=m3sk68syqe.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=emacs-devel@gnu.org \
--cc=grishka@gmx.de \
--cc=monnier@iro.umontreal.ca \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.