From -574318275941208497
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7538bd92d6a9557a
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-16 04:06:25 PST
Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!pipex!jba.co.uk!not-for-mail
From: pollardj@jba.co.uk (Jonathan de Boyne Pollard)
Newsgroups: comp.std.c++
Subject: Re: short enum, bool
Date: 16 Jan 1995 12:06:25 -0000
Organization: JBA Software Products, Studley, England.
Lines: 42
Message-ID: <3fdng1$iti@silver.jba.co.uk>
References: <scottyD2DFML.MDt@netcom.com>
NNTP-Posting-Host: silver.jba.co.uk
X-Newsreader: TIN [version 1.2 PL2]

J Scott Peter (scotty@netcom.com) wrote:
: Forgive me if this has been addressed already.

Not only addressed, but at least one compiler vendor (Metaware) implements
it as an extension to C++.

With High C++, the default for an enum is a "short enum", where the
compiler chooses the minimum width type necessary.  A "long enum" always
gives the enumerated type the same size as int.

( Incidentally, High C++ also has "long long", another extension, for
64-bit integers. )

: This is desirable in order to:
:     Save space.

Which most C++ compilers default to doing anyway.

:     Conform to operating-system structures.  Many structures used by OS
:     system calls contain char-or short-sized fields which have the semantics
:     of a bool or enum.

Fortunately, the default integral promotions and the definitions for
operators (such as operator! and operator&&) mean that most operations on
these fields behave sensibly.

:     [ Suggested addition of a 'byte' modifier. ]
:
:     This is better than using `char' to declare byte-sized integers,

I think that you are trying to solve a non-problem here, simply in the name
of completeness.  I don't know about anyone else, but char, signed char,
and unsigned char have served me well for handling byte-sized data for
years, and apart from the niggles about signedness I've never really wanted
more.

:     Furthermore, you could then distinguish between ASCII characters and
:     byte-sized integers.

Further to my point above, there are very few (if any) practical situations
where "byte-sized integers" (I think that I can guess what you mean) *need*
to be distinguished from ASCII characters.


