Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: Bug in MPW C 2.0.2 print header fil Message-ID: <10178@dartvax.Dartmouth.EDU> Date: 26 Sep 88 16:56:02 GMT References: <10157@dartvax.Dartmouth.EDU> <1234600004@uxf.cso.uiuc.edu> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Society to make my life more fun. Lines: 36 In article <1234600004@uxf.cso.uiuc.edu> emb1354@uxf.cso.uiuc.edu writes: > >Hear Hear! > > This bug was found by myself and a collegue several months ago. The >calls we were making to PrGeneral() were returning garbage values and we >couldn't figure out why. Come to find thefile was screwed. >The funny thing is that such a bug got past everyone in the testing process. >What's the deal? > The keyword is "int." I was investigating the possibility of compiling an Aztec C program which uses the ToolBox using 32-bit ints. In Aztec, an int is 16 bits unless you tell the compiler that it is 32. If things are defined properly as shorts or longs, or typedef'ed to the right size, then the compiler should have no trouble generating a 32 bit application which uses the ToolBox. I "search"ed for "int" in all of the MPW-compatible header files that came with Aztec, and the Printing.h and PrintTraps.h files were the only ones to come up with a significant number of instances of the word "int." This would have to be changed, then, to use this files with the 32-bit switch. Then I looked at the genuine MPW header files to see what Apple said, and it was also int. Since the two compilers have different sized ints, there must be a problem, says I. The moral is this: When using C to call the ToolBox, the data type "int" is strictly for C internal use. We call the ToolBox with shorts or longs, or with things that we have typedef'ed in a header file to be the right size, but never with "int"s! When you get MPW C 3.0, it might be a good idea to search the header file directory for instances of the word "int," just in case. Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755 (603) 643-4109 Sorry, no fancy stuff, since this program limits my .signature to three