Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cmcl2!phri!marob!cowan From: cowan@marob.masa.com (John Cowan) Newsgroups: comp.lang.c Subject: Re: What's a C expert? Message-ID: <1989Jun19.185803.4083@marob.masa.com> Date: 19 Jun 89 18:58:03 GMT References: <12214@well.UUCP> <6057@microsoft.UUCP> Reply-To: cowan@marob.masa.com (John Cowan) Distribution: all Organization: ESCC New York City Lines: 25 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. (Plug: Mch.c also determines the number of bits in ints, shorts, and longs, the number of bits in a char, and the appropriate byte ordering for the machine -- little-endian, big-endian, or mixed. It also makes a partial attempt to determine if the character set is ASCII, EBCDIC or something else.) -- John Cowan or UUCP mailers: ...!uunet!hombre!{marob,magpie}!cowan Fidonet (last resort): 1:107/711 Aiya elenion ancalima!