From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: enum may be signed Date: Mon, 03 May 2010 11:04:41 -0600 Message-ID: References: <4BDC4D04.1040102@gmx.de> Reply-To: Tom Tromey NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1272906576 4881 80.91.229.12 (3 May 2010 17:09:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 3 May 2010 17:09:36 +0000 (UTC) Cc: grischka , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 03 19:09:33 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O8z96-0003C5-0L for ged-emacs-devel@m.gmane.org; Mon, 03 May 2010 19:09:29 +0200 Original-Received: from localhost ([127.0.0.1]:58763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O8z93-0007qS-J9 for ged-emacs-devel@m.gmane.org; Mon, 03 May 2010 13:09:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O8z4c-0006HM-M6 for emacs-devel@gnu.org; Mon, 03 May 2010 13:04:50 -0400 Original-Received: from [140.186.70.92] (port=58543 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O8z4b-0006H3-M3 for emacs-devel@gnu.org; Mon, 03 May 2010 13:04:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O8z4Y-00086I-70 for emacs-devel@gnu.org; Mon, 03 May 2010 13:04:49 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:15678) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8z4X-000860-VI for emacs-devel@gnu.org; Mon, 03 May 2010 13:04:46 -0400 Original-Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o43H4h61022395 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 May 2010 13:04:43 -0400 Original-Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o43H4gie022215; Mon, 3 May 2010 13:04:42 -0400 Original-Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o43H4fhO004412; Mon, 3 May 2010 13:04:42 -0400 Original-Received: by opsy.redhat.com (Postfix, from userid 500) id 5FD7D378183; Mon, 3 May 2010 11:04:41 -0600 (MDT) X-Attribution: Tom In-Reply-To: (Stefan Monnier's message of "Sat, 01 May 2010 13:56:40 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:124475 Archived-At: >>>>> "Stefan" == Stefan Monnier 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