What's a C expert?

John Cowan cowan at marob.masa.com
Tue Jun 20 04:58:03 AEST 1989


In article <6057 at microsoft.UUCP> paulc at 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 <cowan at marob.masa.com> or <cowan at magpie.masa.com>
UUCP mailers:  ...!uunet!hombre!{marob,magpie}!cowan
Fidonet (last resort): 1:107/711
Aiya elenion ancalima!



More information about the Comp.lang.c mailing list