Date: Mon, 20 Nov 2000 17:17:00 +0200 From: Alex Koshterek <havoc@lookanswer.com> To: freebsd-hackers@freebsd.org Subject: Byte order? Message-ID: <00112017175200.47740@pro.lookanswer.com>
next in thread | raw e-mail | index | archive | help
I  know,  that  x86  is  big  endian  architecture
but  simple  programm  like  this:
#include  <stdio.h>
#include  <sys/param.h>
main  ()  {
 /*  Are  we  little  or  big  endian?   From  Harbison&Steele.   */
 union
 {
 long  l;
 char  c[sizeof  (long)];
 }  u;
 u.l  =  1;
 printf  ("Little  endian?  %s\n",  (u.c[sizeof  (long)  -  1]  ==  1)  ?  "yes"  :  "no");
#if  BYTE_ORDER  ==  BIG_ENDIAN
 printf("Big  endian\n");
#elif  BYTE_ORDER  ==  LITTLE_ENDIAN
 printf("Little  endian\n");
#else
 printf("Unknown\n");
#endif
}
Give  me  a  strange  result:
Little  endian?  no
Little  endian
On  my  FreeBSD  4.2-BETA      BYTE_ORDER  =  LITTLE_ENDIAN!
I`m  very  confused  and  some  programms  detect  my  machine  as  Little  Endian,  by
example  freetds.
Alex
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00112017175200.47740>
