🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1936

Range of Enum Constants

#1936
From: Karl Botts
Date: Sun, 04 Nov 1990 08:21
50 lines
1758 bytes
I am sending this to Microsoft; I thought it might be relevent here, too:

/*
Dear Microsoft Online,

	MSC 6.0 correctly compiles this:
*/

enum {
	A = (int)0x8001,
};

/*
	but rejects this:
*/
enum {
	B = (int)0x8000,
};
/*
	with:

enum.c
enum.c(16) : error C2141: value out of range for enum constant

	This doesn't make any sense, since both are valid values for a 
16-bit integer.

	This may be related to something I noticed in <limits.h>:

#define SHRT_MIN	(-32767)	/* minimum (signed) short value */
#define SHRT_MAX	  32767 	/* maximum (signed) short value */

	This is clearly wrong.  I don't have a copy of the ANSI standard, 
but I suppose it is possible that it requires that the the _MIN and _MAX 
constants for a signed integral type have the same absolute value.
If so we'll have to live with it, but otherwise you have a bad header 
file.

	If you have compiled the compiler using your <limits.h> this is
probably the source of the enum problem, above.  But I claim that 
regardless of the ANSI standard, the enum problem is a bug.
*/

/*
	You may wonder how I ran into this.  Well, I have a set of EMS 
access routines which generate error codes by clearing the al register 
if an EMS function fails; the native EMS error codes are in ah, and one
of them is 0x80.  I wanted to make a a set of enum constants for these 
codes.
*/
Technical Details
Message-ID: <1990Nov04.082140.28677@chinet.chi.il.us>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!olivea!orc!inews!iwarp.intel.com!gargoyle!chinet!kdb

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!olivea!orc!inews!iwarp.intel.com!gargoyle!chinet!kdb
From: kdb@chinet.chi.il.us (Karl Botts)
Newsgroups: comp.std.c
Subject: Range of Enum Constants
Message-ID: <1990Nov04.082140.28677@chinet.chi.il.us>
Date: 4 Nov 90 08:21:40 GMT
Organization: Chinet - Public Access UNIX
Lines: 50