From: alain AT qnx DOT com (Alain Magloire) Newsgroups: comp.os.msdos.djgpp Subject: Re: Length of Chars... Date: 26 Jan 2000 02:31:25 GMT Organization: QNX Software Systems Lines: 35 Distribution: world Message-ID: <86lm9t$j54$1@gateway.qnx.com> References: <3888ED7B DOT DF52FEB2 AT ou DOT edu> <38896068 DOT 8C5927C0 AT is DOT elta DOT co DOT il> <388A0530 DOT DF2B2F31 AT ou DOT edu> <86hklo$dot$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <86itfi$l1r$1 AT gateway DOT qnx DOT com> <86jp9i$3u9$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> NNTP-Posting-Host: qnx.com X-Trace: gateway.qnx.com 948853885 19620 209.226.137.1 (26 Jan 2000 02:31:25 GMT) X-Complaints-To: usenet AT qnx DOT com NNTP-Posting-Date: 26 Jan 2000 02:31:25 GMT X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hans-Bernhard Broeker (broeker AT acp3bf DOT physik DOT rwth-aachen DOT de) wrote: : Alain Magloire wrote: : > Hans-Bernhard Broeker (broeker AT acp3bf DOT physik DOT rwth-aachen DOT de) wrote: : > : For short: char, like all the C data types, is implementation defined. : > : You should never assume it's 8 bits, if you can help it, as that : > : renders your program unportable. : > Yes. But If I recall ISO C requires that the size/range of the : > char types be defined in . Althought 8 bits is widely use : > I've heard of implementations that used 9 bits. : Exactly my point: no-one should silently assume char is 8 bits, but : instead look into CHAR_BITS, as defined by the implementation's : to *check* if it really is 8 bits. Or, even better, look up : that value and use it to scale your arrays, if you really feel you : can't allow wasting the bits beyond the 8th that are present in a : char. Yes and I agree, with you. But I don't think, no Compiler vendor in there right mind would redefine char to be anything else the 8 bits, nowadays. I have code that do image manipulation from 8 bits to 32 etc ... and I admit using (char) and (int) to do this ... not good. Essentially, I agree to everything you say, even if the bad coder in me is screamning "bloody murder" ;-). One should use things like inttypes.h where 8 16 32 64 types are defined correctly. Thanks for this reminder, as I was doing the same mistake in my present work. -- au revoir, alain ---- Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!