Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!clyde.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!samsung!zaphod.mps.ohio-state.edu!ub!uhura.cc.rochester.edu!rochester!kodak!uupsi!sunic!news.funet.fi!fuug!mjolner!newshost!eru From: eru@tnvsu1.tele.nokia.fi (Erkki Ruohtula) Newsgroups: comp.arch Subject: Re: 64 bit C Message-ID: Date: 18 Feb 91 15:01:19 GMT References: Sender: news@mjolner.tele.nokia.fi Distribution: comp Organization: Nokia Telecommunications Lines: 52 In-reply-to: marc@marc.watson.ibm.com's message of 14 Feb 91 13:58:51 GMT In article marc@marc.watson.ibm.com (Marc Auslander) writes: >If sizeof int == 8 in 64 bit systems, then the pseudo-invariant sizeof int == >sizeof long == sizeof void* is retained. Any code that relies on such an "invariant" deserves to die. >If sizeof int == 4, then the pseudo-invariant sizeof int == 4 is >retained. (To be less tautological, character/int overlays continue >to work). > >It seems hopeless to make sizeof long == 4. > >The question is - which breaks more code. > >I believe the right answer is the first - and the introduction of new >types which have the same size in all implementations so we can >declare our external protocols in a fixed way. Adding a new type would be wastefull. There already is 4 kinds (or rather families with a signed and unsigned member) of integers, and a 64-bit machine finally lets C to make good use of them all: sizeof(char) = 1, sizeof(short) = 2, sizeof(int) = 4, sizeof(long) = 8 Naturally the ANSI size_t would be defined "unsigned long". I think you are greatly overestimating the difficulty of using C where ints and pointers are of different sizes. In the 8088/80286 "large memory model" C (which probably is the horror story that opponents of mixed sizes are remembering) the problem is not really the difference between the sizes of int and pointer, but the fact that the pointer is not coded linearly, the small size of the segment that can be addressed linearly with an array access or pointer addition (64k), and the small size of int (16 bits), which runs out in many applications. The 32-bit int/64-bit pointer would be much, much easier. Using ANSI C with prototypes for all functions helps immensely in getting ints and pointers straight. I have successfully ported some 32-bit code to 8088 large memory model by making prototypes with automated tools and heeding what the compiler (or lint) says with maximal warnings. If prototypes are used right from the start and a checking compiler (or lint) is kept happy, this kind of operation will not be necessary at all when going from 32 to 64 bits. >Anyone out there for sizeof int == 4? Yes! -- Erkki Ruohtula / Nokia Telecommunications eru@tele.nokia.fi / P.O. Box 33 SF-02601 Espoo, Finland Disclaimer: These are my private opinions and do not represent the position of Nokia Telecommunications.