Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!snorkelwacker!bloom-beacon!eru!luth!sunic!nuug!ifi!is.uu.no!ra From: ra@is.uu.no (Robert Andersson) Newsgroups: comp.lang.c Subject: How to write an 8-bit clean program Message-ID: <1990Feb10.151053.16702@is.uu.no> Date: 10 Feb 90 15:10:53 GMT Organization: International Systems A/S, Oslo, Norway. Lines: 36 An important subject for us Europeans with all our strange character sets. But, what is the best way to do it? Of course, using the eight bit as a flag, assuming that letters range from 'A' to 'Z' etc. are well known things to avoid, and that is not what I would like to discuss. What I would like is to hear other peoples opinion on the signed/unsigned char issue. The type 'char' as defined in C on some implementations range from -127 to 128, on others from 0 to 255. The rest of this message assumes the compiler has signed chars as a default. In an 8-bit set some character will have values > 128. Is it kosher to store these values in char variables? Suppose you do it, then as long as you simply use char variables in simple assignments/test or as buffers, all is probably OK. As soon as you use the variable in arithmetic expressions or assigments to other types things become more muddy. So, the better way to do it might be to change all char variables in your program to unsigned char? But that opens another can of worms. Many compilers spit out warnings for expression like: unsigned char *junk = "morejunk"; lint dislikes things like: unsigned char buff[100]; write(fd, buff, 100); Of course you could add casts in all those places, but is sort of doesn't 'feel' right to do that. It seems you lose in either case. Opinions? -- Robert Andersson, International Systems A/S, Oslo, Norway. Internet: ra@is.uu.no UUCP: ...!{uunet,mcsun,ifi}!is.uu.no!ra