[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: enum may be signed

From: grischka
Subject: Re: enum may be signed
Date: Sat, 01 May 2010 20:51:11 +0200
User-agent: Thunderbird (Windows/20090812)

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:

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]