Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!decwrl!adobe!hawley From: hawley@adobe.COM (Steve Hawley) Newsgroups: comp.sys.mac.programmer Subject: Re: Can THINK C support wider types than normal? Message-ID: <6910@adobe.UUCP> Date: 1 Oct 90 00:35:43 GMT References: <9216@potomac.ads.com> Reply-To: hawley@adobe.UUCP (Steve Hawley) Organization: Adobe Systems Incorporated, Mountain View Lines: 42 In article <9216@potomac.ads.com> jtn@potomac.ads.com (John T. Nelson) writes: > >I know that THINK C uses 16 bit wide fields to store its int's and 32 >for longs, I have a piece of software, however, that would REALLY like >to see 32-bit wide int's and the other types that Sun computers >support. > >If THINK C can't accomodate longer types with some magic macro or >switch then it means I'll have to redefine a LOT of code. > >Any ideas? Think C probably uses 16 bit ints because of the following sentiment in Kernighan & Ritchie: int an integer, typically the natural size of integers on the host machine. The Mac (and Think C) started with a 68000 processor which can do 16 bit arithmetic with single instructions for all the basic operators. Since 32-bit multiplies and divides require the use of library routines, this doesn't seem like a natural data type to be used as a default. Since then the Mac has grown up a bit, and certain machines (with 68020s or 68030's) can now do 32-bit arithmetic with a single instruction without the performance hit you would get on a 68000 using library routines. Think C (to my knowledge) has no provision for generating code for 32-bit ints without explicitly using the long data type. Add the following code to each of your files: #ifdef THINK_C /* I think this is correct - check the manual */ #define int long /* a typedef might work too */ #endif -or- revamp your entire code to abstract the int data type to something else, so you never actually use int. Steve Hawley hawley@adobe.com -- "I'm sick and tired of being told that ordinary decent people are fed up with being sick and tired. I know I'm certainly not, and I'm sick and tired of begin told that I am." -Monty Python