delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/22/12:31:30

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Length of Chars...
Date: Sat, 22 Jan 2000 09:46:48 +0200
Organization: NetVision Israel
Lines: 36
Message-ID: <38896068.8C5927C0@is.elta.co.il>
References: <3888ED7B DOT DF52FEB2 AT ou DOT edu>
NNTP-Posting-Host: ras1-p17.rvt.netvision.net.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 948527208 19075 62.0.172.19 (22 Jan 2000 07:46:48 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 22 Jan 2000 07:46:48 GMT
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en,ru,hebrew
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

David Cleaver wrote:
> 
> I was wondering if there were any plans on changing the number of bits
> in char from 8 to 16 or something like that?

No.  I don't think any compiler in the world does, or is about to do, that.

Programs that need more than 8 bits in a character, should use the wide
character (wchar_t) data type provided by the ANSI standard, and the
multibyte character representation that goes with it.  (Unfortunately, the
DJGPP library doesn't support this type very well, the associated functions
only work in the "C" locale, i.e. for single-byte characters.  Volunteers are
welcome to work on this.)

> Ok, well, the real problem is that I'm writing a program that is very
> dependent on the char data type being 8-bits.

I'm not sure I understand the context (so please feel free to explain more),
but the usual way to handle these situations is to define a data type (with
`typedef') that is as wide as you want, and then use it for those variables
which need to be of that width.

> Which brings me to my second (completely unrelated) point...  Why can't
> the primitive data type names reflect how many bits are being used in
> their storage?

I think the next C Standard (C9X, as it is called) addresses this to some
extent.  Can someone who has the draft handy please confirm?

> I think this would help out
> alot so that programs could be written more with storage in mind.

Keep in mind that many programs don't care much about the storage in many
cases.  For example, when you code a simple for loop which is going to be
executed a few dozen times, you want the fastest data type, no matter what
the storage is.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019