jtn@potomac.ads.com (John T. Nelson) (10/01/90)
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. There seem to be two schools of thought here.... 1. the 68000, has a 16-bit bus, so int should be 16 bits 2. the 68000 has 32 bit registers, so int should be 32 bits Type 1 compilers keep their stacks two-byte aligned; they push two bytes when passing an char or an int and four when passing a long. Type 2 compilers widen all parameters to four bytes. Type 1s have a performance advantage on 68000 and 68010, but their programs die if you pass a two-byte quantity to a function expecting a four byter. Type 2s are slow on 68000/010, but catch up on 68020 and above; they are also much more tolerant of char/short/int/long confusion. Any ideas? -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ORGANIZATION: Advanced Decision Systems GEOGRAPHIC: Arlington, VA UUCP: kzin!speaker@mimsy.umd.edu INTERNET: jtn@potomac.ads.com SPOKEN: Yo... John! PHONE: (703) 243-1611 PROJECT: The Conrail Locomotive/Harpsichord Fusion Program =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
hawley@adobe.COM (Steve Hawley) (10/01/90)
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
minich@d.cs.okstate.edu (Robert Minich) (10/01/90)
>>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. > 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 This will probably fail when you do something like printf("%d", <int>) so you have to go in and be sure to fix all those dependencies. I don't know how difficult it would be but it would be REAL NICE (anyone at Symantec listening?) REAL REAL NICE if we could check a box in the copiler option dlog to change that. TC is sill a great compiler. I just want to see it get bettter. > -or- > revamp your entire code to abstract the int data type to something else, > so you never actually use int. This is probably the best way to go. > Steve Hawley > hawley@adobe.com -- |_ /| | Robert Minich | |\'o.O' | Oklahoma State University| A fanatic is one who sticks to |=(___)= | minich@d.cs.okstate.edu | his guns -- whether they are | U | - Ackphtth | loaded or not.