Subject: Re: CVS commit: basesrc
To: Tim Rightnour <root@garbled.net>
From: Greg A. Woods <woods@weird.com>
List: source-changes
Date: 11/10/2000 13:52:14
[ On Friday, November 10, 2000 at 08:46:08 (-0700), Tim Rightnour wrote: ]
> Subject: Re: CVS commit: basesrc
>
> While I do agree with you on that point.. It does seem like there should be a
> way to determine the endianess of the machine you are attempting to build for.

#include <stdio.h>

/*
 * from Harbison & Steele, 4th ed., pg. 164
 */

union {
        long mylong;
        char mychar[sizeof(long)];
} un;

int
main()
{
        un.mylong = 1;
        if (un.mychar[0] == 1)
                printf("Addressiong is right-to-left (little-endian).\n");
        else if (un.mychar[sizeof(long)-1] == 1)
                printf("Addressing is left-to-right (big-endian).\n");
        else
                printf("Addressing is strange (pdp11?).\n");
        exit(0);
}

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>