Xref: utzoo comp.lang.c++:13168 comp.lang.c:38889 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!munnari.oz.au!bruce!trlluna!titan!llama.trl.OZ.AU!peter From: peter@llama.trl.OZ.AU (Peter Richardson - NSSS) Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: 64 bit architectures and C/C++ Message-ID: <1991May1.023356.8048@trl.oz.au> Date: 1 May 91 02:33:56 GMT References: <168@shasta.Stanford.EDU> <4068@inews.intel.com> Sender: news@trl.oz.au (USENET News System) Reply-To: peter@llama.trl.OZ.AU (Peter Richardson - NSSS) Organization: Telecom Research Laboratories, Melbourne, Australia Lines: 55 In article <4068@inews.intel.com>, bhoughto@pima.intel.com (Blair P. Houghton) writes: > In article <168@shasta.Stanford.EDU> shap@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@trl.oz.au X400: g=peter s=richardson ou=trl o=telecom prmd=telecom006 admd=telememo c=au