From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 23894 invoked from network); 22 Jun 1998 19:47:42 -0000 Received: from ns.blueskystudios.com (208.5.132.2) by mail2.redhat.com with SMTP; 22 Jun 1998 19:47:42 -0000 Received: from scotia ([199.165.156.54]) by ns.blueskystudios.com (Netscape Mail Server v2.0) with SMTP id AAA7189; Mon, 22 Jun 1998 15:54:08 -0400 Sender: hadsell@blueskystudios.com (Dick Hadsell) Message-ID: <358EB62A.446B@blueskystudios.com> Date: Mon, 22 Jun 1998 15:53:14 -0400 From: Richard Hadsell Organization: Blue Sky | VIFX X-Mailer: Mozilla 3.01 (X11; I; IRIX 6.2 IP22) MIME-Version: 1.0 To: axp-list@redhat.com Subject: Re: Making programs 64 bit clean References: <199806221735.NAA13258@adder.cs.Virginia.EDU> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Greg Lindahl wrote: > > > Is this an acceptable solution to making programs 64 bit clean and is it > > portable across 32 bit and 64 bit platforms? > > This is the easiest way to fix broken code. However, it isn't > necessarily portable to other 64 bit machines -- I think everyone > else (?) defines long == 32 bits and long long == 64 bits. > > Your best bet for a clean, easy solution is to typedef an int64 type > and use that, with an appropriate definition for each machine. If you > are clever you can put that into a configure script... If you have to do it, long has been the traditionally safe way to convert between integers and pointers. I can't find where I read that, but the ARM said in sec. 5.4, "A pointer converted to an integer of sufficient size (if any such exists on the implementation) and back to the same pointer type will have its original value; ..." I haven't heard of any platforms for which long is smaller than a pointer; long long is not yet supported on some compilers, so I wouldn't rely at all on its portability. So I use long, when necessary. Of course, I do it through a typedef (iptr) that I define in a header that has other machine-dependent typedefs. I wouldn't waste space and performance by forcing 32-bit pointers through an int64. -- Dick Hadsell 914-381-8400 Fax: 914-381-9790 Reply-to: hadsell@blueskystudios.com Blue Sky | VIFX http://www.blueskystudios.com 1 South Road, Harrison, NY 10528