From: Daniel A. S. <st...@ic...> - 2005-06-19 13:28:17
|
Mats, On Sunday, Jun 19, 2005, at 23:12 Australia/Sydney, Mats Bengtsson wrote: > It would be good to have something compiler independent since > the same code is used in VC++ as well. > Tcl does: > union { > char c[sizeof(short)]; > short s; > } order; > order.s = 1; > Tcl_SetVar2(interp, "tcl_platform", "byteOrder", > ((order.c[0] == 1) ? "littleEndian" : "bigEndian"), > TCL_GLOBAL_ONLY); of course this type of check only works at runtime; at build time, you need to do something like the WORDS_BIGENDIAN check that I just committed to tcl/generic/tclInt.h (c.f. earlier mail on this list), which should be cross platform across unices. On windows, you can safely assume little endian, as it doesn't run on any big-endian processors, no ? Cheers, Daniel -- ** Daniel A. Steffen ** "And now for something completely ** Dept. of Mathematics ** different" Monty Python ** Macquarie University ** <mailto:st...@ma...> ** NSW 2109 Australia ** <http://www.maths.mq.edu.au/~steffen/> |