Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!husc6!harvard!seismo!hao!hplabs!hpda!hpisoa2!hpitg!utcsri!greg@utcsri From: greg@utcsri Newsgroups: net.lang.c Subject: Re: Byte order (retitled) Message-ID: <2637@utcsri> Date: Sat, 26-Apr-86 01:59:00 EDT Article-I.D.: utcsri.2637 Posted: Sat Apr 26 01:59:00 1986 Date-Received: Tue, 13-May-86 03:09:14 EDT References: <7046@cca> Lines: 29 In article <1117@psivax.UUCP> friesen@psivax.UUCP (Stanley Friesen) writes: >In article <2590@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes: >>... > And I am saying that the following *should* be portable, and >that any implementation that it doesn't work on is brain-damaged. > > register int i; > unsigned char bytes[ sizeof( long )]; /* lo-byte first */ > long input; > register char *cvptr; > > for(cvptr = (char *)&input, i = 0; i < sizeof(long); i++) > bytes[i] = cvptr[i]; > Sorry - I thought you were suggesting that big-endian pointer conversions should set the lower bits (when pointing to a smaller object) and clear them (when pointing to a larger one). What you are actually saying is that any implementation which is not strictly little-endian is 'brain- damaged' (Including (a) PDP11 _longs_, (b) 68000). I will agree that (a) is brain-damaged, but I think the adjective is a little strong for (b). I am a little-end fan myself, but I can face reality, and the reality is there will be big-endian machines around that are still worth using, and that the 'problem' can be dealt with so easily that one needn't damn the 68K to eternal flames on this one point. -- "For every action there is an equal and opposite malfunction" ---------------------------------------------------------------------- Greg Smith University of Toronto UUCP: ..utzoo!utcsri!greg