Path: utzoo!utgpu!watmath!julian!uwovax!2014_5001 From: 2014_5001@uwovax.uwo.ca Newsgroups: comp.lang.c Subject: Re: Signed/Unisgned chars (Was: What's a C expert?) Message-ID: <2382@uwovax.uwo.ca> Date: 27 Jun 89 10:12:08 GMT References: <12214@well.UUCP> <6057@microsoft.UUCP> <1989Jun19.185803.4083@marob.masa.com> <2379@uwovax.uwo.ca> Lines: 25 Organisation: University of Western Ontario, Canada In article <2379@uwovax.uwo.ca>, 2014_5001@uwovax.uwo.ca writes: > In article <1989Jun19.185803.4083@marob.masa.com>, cowan@marob.masa.com (John Cowan) writes: >> In article <6057@microsoft.UUCP> paulc@microsoft.UUCP (Paul Canniff 2/1011) writes: >>>[A expert in C] can tell why the following code >>>prints "false" (on 8-bit char systems). >>> >>> char x = 0xff; >>> >>> if (x != 0xff) >>> printf("FALSE\n"); >> >> An expert in >portable< C, OTOH, knows that whether this code prints "FALSE" >> (not "false") is system-dependent, since whether chars are signed or unsigned >> is system-dependent. In fact, my program "mch.c", which is compiled on a >> given system to determine various system-dependent facts about it and print >> them out as a set of #defines uses logic much like this to decide whether >> chars are signed or unsigned. >> > Howvwer in real C (ANSI C) chars are guaranteed signed. > Sorry. I was wrong, but the docs that came with my C compiler said that ANSI guaranteed signed chars by default. Thanx for telling me of my error. In fact the documentation says that the compiler switched defaults to conform with ANSI. (My compiler is turbo C).