From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,82d87c508dfbdc4 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-10-17 13:17:31 PST Newsgroups: comp.unix.osf.osf1 Path: bga.com!news.sprintlink.net!howland.reston.ans.net!swrinde!news.uh.edu!uuneo.neosoft.com!nmtigw!peter From: peter@nmti.com (Peter da Silva) Subject: Re: help, malloc 32 vs malloc 64 Message-ID: Sender: peter@nmti.com (peter da silva) Organization: Network/development platform support, NMTI References: <37om6o$s79@csugrad.cs.vt.edu> Date: Mon, 17 Oct 1994 16:53:57 GMT In article <37om6o$s79@csugrad.cs.vt.edu>, Teak 'Teakster' Min wrote: > Problem: I am working on a DEC Alpha using OSF/1. I need to know > if there is anyway to #define an int in C to a long. What I am > having problems is that when I malloc and I get a memory location, > the address is assigned to a pointer of type int which is 32bit but > the system gives back an address with is greater than 32bit address. No, a pointer to an integer is 64 bits wide. An integer is 32 bits wide. It is not possible in general to assign a pointer to an integer. For about 8-10 years the majority of high performance platforms did have an integer that was the same size as a pointer, and people have written code that depends on this implementation detail, but the language itself does not guarantee it. The fix is to change your code so it no longer tries to store a pointer in an integer. > I know that OSF is a 64 bit architecture. What I need to know is > how to compile my program which will use only address in the > 32bit range OR set on option that will make int larger than 32bit. Neither is possible or desirable. > This program (or I should say environment) is compiled using both > cc and gcc. I was TOLD that c was a portable code, was I lied to? If you were told that this program was portable, you were lied to. If you were told that it is possible to write portable code in C, that is the truth. It is possible to write portable code in C, however that doesn't imply that all code written in C is portable. > Why not change all my int to long? Well this program has over a > hundred if not more files in several directories and I wish not > to go in all those files and change int to long. That's good, because that's not what you need to do. What you need to do is fix the broken code that assumes that you can store a pointer in an integer. If you don't wish to do that, there's no doubt many people on the net who will be willing to do it for you for a reasonable fee. -- Peter da Silva `-_-' Network Management Technology Incorporated 'U` 1601 Industrial Blvd. Sugar Land, TX 77478 USA +1 713 274 5180 "Hast Du heute schon Deinen Wolf umarmt?"