home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!usc!rpi!uwm.edu!ogicse!cs.uoregon.edu!sisters.cs.uoregon.edu!mkelly
- From: mkelly@sisters.cs.uoregon.edu (Michael A. Kelly)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Think C MacHeaders weirdness
- Message-ID: <1992Sep10.201526.502@cs.uoregon.edu>
- Date: 10 Sep 92 20:15:26 GMT
- References: <72240@apple.Apple.COM> <BuD46B.7Cp@world.std.com>
- Sender: news@cs.uoregon.edu (Netnews Owner)
- Organization: University of Oregon Computer and Information Sciences Dept.
- Lines: 51
-
- In article <BuD46B.7Cp@world.std.com> siegel@world.std.com (Rich Siegel) writes:
- >In article <72240@apple.Apple.COM> mkelly@Apple.COM (Michael Kelly) writes:
- >>
- >>OK, this is strange. I had a simple program that first initialized the
- >>toolbox with InitFonts, etc., in the correct order, and then went on to
- >>make some File Manager calls. The initialization routine was in a separate
- >>file from both main and the rest of the program. I wasn't including
- >>MacHeaders in the Prefix. I ran the program with the debugger, and it
- >>crashed violently in the toolbox initialization routine. I tried a few
- >>things, none of which made any difference. I finally #included MacHeaders
- >>at the top of the file, and then it worked. Weird.
- >>
- >>The next call was in a different file. It was to FSMakeFSSpec, which failed,
- >>saying the volume didn't exist. There was nothing wrong with the call. I
- >>#included MacHeaders, on a whim, in that file, and magically the function
- >>worked as it should.
- >>
- >>The next call was to OpenWD, in yet another file. It stopped in the
- >>debugger with a bus error inside MacTraps2. "Well, this is silly," I
- >>thought, and I put MacHeaders in the Prefix. Now the program works as
- >>it should (well, except for some other unrelated things....)
- >>
- >>So, any ideas? Has anyone run into this sort of weirdness before?
- >
- >No wierdness at all. All of the calls you've mentioned here are implemented
- >through glue in an external library (MacTraps and MacTraps2 in this case).
- >Since you called them with the correct spelling, you didn't get link errors,
- >but because you didn't include either <MacHeaders> or the appropriate
- >Toolbox headers (File.h would be appropriate here), the compiler rightly
- >concluded that the undeclared functions used the C calling convention
- >and returned an 'int'. Bad news, since all Toolbox calls are 'pascal'
- >functions. By including <MacHeaders>, you get declarations for all of
- >the functions whose functions are prototyped in the headers that
- >MacHeaders was built from, so this doesn't happen.
- >
- >R.
-
- OK, I believe you. That definitely explains the File Manager calls, since
- I had Infer Prototypes on (not my fault) and I don't think I was including
- File.h in the files that used the File Manager. But, I was including the
- appropriate headers for the InitMacintosh function (Dialogs.h, Menus.h, etc.)
- and it was crashing there before it got to the file calls.
-
- Oh well, as long as it works....
-
- Mike.
- --
- _____________________________________________________________________________
- Michael A. Kelly University of Oregon
- mkelly@cs.uoregon.edu Computer Science Department
- _____________________________________________________________________________
-