home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15301 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  3.3 KB

  1. 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
  2. From: mkelly@sisters.cs.uoregon.edu (Michael A. Kelly)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Think C MacHeaders weirdness
  5. Message-ID: <1992Sep10.201526.502@cs.uoregon.edu>
  6. Date: 10 Sep 92 20:15:26 GMT
  7. References: <72240@apple.Apple.COM> <BuD46B.7Cp@world.std.com>
  8. Sender: news@cs.uoregon.edu (Netnews Owner)
  9. Organization: University of Oregon Computer and Information Sciences Dept.
  10. Lines: 51
  11.  
  12. In article <BuD46B.7Cp@world.std.com> siegel@world.std.com (Rich Siegel) writes:
  13. >In article <72240@apple.Apple.COM> mkelly@Apple.COM (Michael Kelly) writes:
  14. >>
  15. >>OK, this is strange.  I had a simple program that first initialized the
  16. >>toolbox with InitFonts, etc., in the correct order, and then went on to
  17. >>make some File Manager calls.  The initialization routine was in a separate
  18. >>file from both main and the rest of the program.  I wasn't including
  19. >>MacHeaders in the Prefix.  I ran the program with the debugger, and it
  20. >>crashed violently in the toolbox initialization routine.  I tried a few
  21. >>things, none of which made any difference.  I finally #included MacHeaders
  22. >>at the top of the file, and then it worked.  Weird.
  23. >>
  24. >>The next call was in a different file.  It was to FSMakeFSSpec, which failed,
  25. >>saying the volume didn't exist.  There was nothing wrong with the call.  I
  26. >>#included MacHeaders, on a whim, in that file, and magically the function
  27. >>worked as it should.
  28. >>
  29. >>The next call was to OpenWD, in yet another file.  It stopped in the
  30. >>debugger with a bus error inside MacTraps2.  "Well, this is silly," I
  31. >>thought, and I put MacHeaders in the Prefix.  Now the program works as
  32. >>it should (well, except for some other unrelated things....)
  33. >>
  34. >>So, any ideas?  Has anyone run into this sort of weirdness before?
  35. >
  36. >No wierdness at all. All of the calls you've mentioned here are implemented
  37. >through glue in an external library (MacTraps and MacTraps2 in this case).
  38. >Since you called them with the correct spelling, you didn't get link errors,
  39. >but because you didn't include either <MacHeaders> or the appropriate
  40. >Toolbox headers (File.h would be appropriate here), the compiler rightly
  41. >concluded that the undeclared functions used the C calling convention
  42. >and returned an 'int'. Bad news, since all Toolbox calls are 'pascal'
  43. >functions. By including <MacHeaders>, you get declarations for all of
  44. >the functions whose functions are prototyped in the headers that
  45. >MacHeaders was built from, so this doesn't happen.
  46. >
  47. >R.
  48.  
  49. OK, I believe you.  That definitely explains the File Manager calls, since 
  50. I had Infer Prototypes on (not my fault) and I don't think I was including
  51. File.h in the files that used the File Manager.  But, I was including the
  52. appropriate headers for the InitMacintosh function (Dialogs.h, Menus.h, etc.)
  53. and it was crashing there before it got to the file calls.
  54.  
  55. Oh well, as long as it works....
  56.  
  57. Mike.
  58. -- 
  59. _____________________________________________________________________________
  60. Michael A. Kelly                                         University of Oregon
  61. mkelly@cs.uoregon.edu                             Computer Science Department
  62. _____________________________________________________________________________
  63.