Path: utzoo!attcan!uunet!cs.utexas.edu!usc!ucsd!network.ucsd.edu!celit!soledad!keck From: keck@sea.com (John Keck) Newsgroups: comp.lang.c Subject: Re: Preprocessor code to figure out endianness ? Message-ID: <1990Sep15.202256.2992@sea.com> Date: 15 Sep 90 20:22:56 GMT References: <28803:Sep1221:34:1690@kramden.acf.nyu.edu> Organization: Systems Engineering Associates Lines: 19 In article <28803:Sep1221:34:1690@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: > [...] > >int hilo_magic = 1212958796; char *hilo = (char *) &hilo_magic; > >hilo[0]hilo[1] is "HL" on machines that place the high byte first and >"LH" on others. It even works on sixteen-bit machines, provided the >compiler reduces 1212958796 to 18508. > >---Dan As long as they use the ASCII character set. -- John Keck INTERNET:keck@sea.com UUCP:...!ucsd!soledad!keck VOICE:619/581-6181 Systems Engineering Associates, 2204 Garnet Ave Suite 203, San Diego CA 92109 ----------------------------------------------------------------------------- "Much speech leads inevitably to silence. Better to hold fast to the void."