unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: grischka <grishka@gmx.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: enum may be signed
Date: Sat, 01 May 2010 20:51:11 +0200	[thread overview]
Message-ID: <4BDC781F.5050609@gmx.de> (raw)
In-Reply-To: <jwvmxwjo6gr.fsf-monnier+emacs@gnu.org>

Stefan Monnier wrote:
>> +  enum symbol_redirect redirect : 3;
> 
>> Note that this breaks with compilers where enums can be signed (e.g. MSVC),
>> Because value 4 doesn't fit into 3 bits (signed), it is read as -4 and
>> breaks related switch statements (e.g. data.c:set_internal)
> 
> Interesting.  I didn't know about that part of the C language.  Is it
> possible to specify that this is an unsigned enum somehow?
> I've tried "enum symbol_redirect redirect : 3;" but at least GCC didn't
> like it.

Planned for C++0x:
http://en.wikipedia.org/wiki/C%2B%2B0x#Strongly_typed_enumerations

> Of course we can add one more bit (we have plenty of bits left there),
> but I'd first like to know how this is usually handled, since it seems
> to imply that MSVC always requires one extra bit to store enums.

Good old "unsigned redirect : 3;" works as expected.

Btw, check also "enum Lisp_Type type : GCTYPEBITS;".

--- grischka

> 
> 
>         Stefan
> 





  parent reply	other threads:[~2010-05-01 18:51 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 [this message]
2010-05-03 17:04   ` Tom Tromey

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BDC781F.5050609@gmx.de \
    --to=grishka@gmx.de \
    --cc=emacs-devel@gnu.org \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).