64 bit architectures and C/C++

Peter Richardson - NSSS peter at llama.trl.OZ.AU
Wed May 1 12:33:56 AEST 1991


In article <4068 at inews.intel.com>, bhoughto at pima.intel.com (Blair P.
Houghton) writes:
> In article <168 at shasta.Stanford.EDU> shap at shasta.Stanford.EDU (shap) writes:
> >It seems to me that 64 bit architectures are going to
> >introduce some nontrivial problems with C and C++ code.
> 
> Nope.  They're trivial if you didn't assume 32-bit architecture,
> which you shouldn't, since many computers still have 36, 16, 8,
> etc.-bit architectures.
> 
> >I want to start a discussion going on this topic.  Here are some seed
> >questions:

Hmmm. As I understand it. if you want to write truly portable code, you
should never make assumptions about sizeof any integral types. We have
a local header file on each machine type defining Byte, DoubleByte etc.
For example, on sun4:

typedef unsigned char Byte;             // always a single byte
typedef unsigned short DoubleByte;      // always two bytes
typedef unsigned long QuadByte;         // always four bytes

If you want to use an int, use an int. If you want to use a 16 bit
quantity, use a DoubleByte. To port to new machines, just change the
header file. Purists may prefer "Octet" to "Byte".

It is up to the platform/compiler implementation to determine the
appropriate sizeof integral types. It should not be part of the
language.

> 
> Poorly, if at all.  Data transmission among architechures
> with different bus sizes is a hairy issue of much aspirin.
> The only portable method is to store and transmit the data
> in some width-independent form, like morse-code or a text
> format (yes, ascii is a 7 or 8 bits wide, but it's a
> _common_ form of data-width hack, and if all else fails,
> you can hire people to read and type it into your
> machine).

There is an international standard for doing this, called Abstract
Syntax Notation One (ASN.1), defined by ISO. It is based on the CCITT
standards X.208 and X.209 (I think). It is more powerful than either of
the proprietary standards XDR or NDR. Compilers are used to translate
ASN.1 data descriptions into C/C++ structures, and produce
encoder/decoders.  

---
Peter Richardson 		         Phone: +61 3 541-6342
Telecom Research Laboratories 	           Fax: +61 3 544-2362
					 Snail: GPO Box 249, Clayton, 3168
                                                Victoria, Australia
Internet: p.richardson at trl.oz.au
X400: g=peter s=richardson ou=trl o=telecom prmd=telecom006 admd=telememo c=au



More information about the Comp.lang.c mailing list