[TriLUG] OT: network byte order double swapping

Ed Hill ed at eh3.com
Mon Apr 4 13:21:46 EDT 2005


On Mon, 2005-04-04 at 12:51 -0400, Brian Weaver wrote: 
> 
> Any chance you could enlighten those of us without access to 64-bit
> machines what the sizeof operator returns in your little program?

Hi Brian,

Sure, on a typical 64-bit system you'll see:

cat <<EOF > tst.c
#include "stdio.h"
int main (int argc, char ** argv)
{
   printf("sizeof(long) = %d\n",sizeof(long));
   printf("sizeof(unsigned long) = %d\n",sizeof(unsigned long));
   printf("sizeof(long long) = %d\n",sizeof(long long));
   return 0;
}
EOF
make tst
./tst
sizeof(long) = 8
sizeof(unsigned long) = 8
sizeof(long long) = 8

so beware of the variable sizeof(...)'s.  AMD64, PPC64, and EM64T are
becoming quite popular.  Its likely that, in less than two years, most
chips sold (inc. laptops) will be 64-bit-capable.

Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Rm 54-1424;  77 Massachusetts Ave.
             Cambridge, MA 02139-4307
emails:  eh3 at mit.edu                ed at eh3.com
URLs:    http://web.mit.edu/eh3/    http://eh3.com/
phone:   617-253-0098
fax:     617-253-4464




More information about the TriLUG mailing list