home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!spool.mu.edu!sol.ctr.columbia.edu!eff!world!siegel
- From: siegel@world.std.com (Rich Siegel)
- Subject: Re: Think C MacHeaders weirdness
- Message-ID: <BuD46B.7Cp@world.std.com>
- Organization: GCC Technologies
- References: <72240@apple.Apple.COM>
- Date: Thu, 10 Sep 1992 12:32:34 GMT
- Lines: 43
-
- 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.
-
-
-
- --
- -----------------------------------------------------------------------
- Rich Siegel Internet: siegel@world.std.com
- Software Engineer & Toolsmith
- GCC Technologies
-