Newsgroups: | comp.arch,comp.compilers |
From: | paysan@informatik.tu-muenchen.de (Bernd Paysan) |
Keywords: | C, architecture, comment |
Organization: | Technische Universitaet Muenchen, Germany |
References: | <4074ig$nh7@masala.cc.uh.edu> 95-08-120 |
Date: | Mon, 21 Aug 1995 02:02:15 GMT |
doconnor@sedona.intel.com (Dennis O'Connor -FT-~) wrote:
> If the C standard specified a flag or pair of flags that the
> compiler would set to indicate whether the target architecture
> was big- or little-endian, that would be a big help.
Yes.
> So, how about it, GNU and ANSI ? Let's see __BIGEND__
> and __LITTLEEND__ incorporated into the standards.
> Thanks.
I would support your request. Especially I found out that it is quite a
problem not having anything that you can rely on. E.g. when we (that's
Anton Ertl and me) started writing gforth, we used a macro BIGENDIAN
that was only defined, when the machine was b.e.. No we compiled under
Linux, and (surprise!) the program didn't work correct. Why? Linux'
include files define BIGENDIAN 0 when the machine is l.e., and BIGENDIAN 1
if it is b.e. :-(. Now we use WORDS_BIGENDIAN (that's what autoconf uses)
and hope, that this is unique...
> [How often in otherwise platform independent code do you really need to know
> the byte order? I've almost always been able to program around it without
> much trouble. -John]
In code where you desire to have a specified byte order, thus read/writing
binary file formats accross platforms, network code, or (this is where I
need it ;-) processor simulation (because the simulated processor isn't
wanted to inherit the host's byte order).
--
Bernd Paysan
http://www.informatik.tu-muenchen.de/~paysan/
[For reading and writing binary files, I've had great success using shifts,
masks, getc(), and putc() to assemble and disassemble multi-byte data on
the way in or out. I agree that there are some places where knowing the
byte order makes life easier. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.