Re: Help: How to determine big/little endian?

paysan@informatik.tu-muenchen.de (Bernd Paysan)
Mon, 21 Aug 1995 02:02:15 GMT

          From comp.compilers

Related articles
Re: Help: How to determine big/little endian? doconnor@sedona.intel.com (1995-08-17)
Re: Help: How to determine big/little endian? ECE@dwaf-hri.pwv.gov.za (John Carter) (1995-08-21)
Re: Help: How to determine big/little endian? baynes@ukpsshp1.serigate.philips.nl (1995-08-21)
Re: Help: How to determine big/little endian? pardo@cs.washington.edu (1995-08-21)
Re: Help: How to determine big/little endian? mw@ipx2.rz.uni-mannheim.de (1995-08-22)
Re: Help: How to determine big/little endian? tonyk@cybercom.net (1995-08-22)
Re: Help: How to determine big/little endian? paysan@informatik.tu-muenchen.de (1995-08-21)
Re: Help: How to determine big/little endian? tim@franck.Princeton.EDU (1995-08-25)
Re: Help: How to determine big/little endian? meissner@cygnus.com (Michael Meissner) (1995-08-25)
Re: Help: How to determine big/little endian? cwf@research.att.com (Chris Fraser) (1995-08-25)
Re: Help: How to determine big/little endian? nr@cs.purdue.edu (1995-08-25)
Re: Help: How to determine big/little endian? doug@netcom.com (1995-08-26)
Re: Help: How to determine big/little endian? meissner@cygnus.com (Michael Meissner) (1995-09-01)
[4 later articles]
| List of all articles for this month |

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]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.