Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!sdrc!thor!scjones From: scjones@thor.UUCP (Larry Jones) Newsgroups: comp.lang.c Subject: Re: Preprocessor code to figure out endianness ? Message-ID: <176@thor.UUCP> Date: 13 Sep 90 14:26:08 GMT References: <28803:Sep1221:34:1690@kramden.acf.nyu.edu> Organization: SDRC, Cincinnati Lines: 16 In article <28803:Sep1221:34:1690@kramden.acf.nyu.edu>, brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: > on the occasions when I need to know byte order, I use something like > > 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. Gee, it doesn't seem to work at all on my IBM 3090.... ---- Larry Jones UUCP: uunet!sdrc!thor!scjones SDRC scjones@thor.UUCP 2000 Eastman Dr. BIX: ltl Milford, OH 45150-2789 AT&T: (513) 576-2070 I always have to help Dad establish the proper context. -- Calvin