home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15279 < prev    next >
Encoding:
Text File  |  1992-09-10  |  2.4 KB  |  54 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!spool.mu.edu!sol.ctr.columbia.edu!eff!world!siegel
  3. From: siegel@world.std.com (Rich Siegel)
  4. Subject: Re: Think C MacHeaders weirdness
  5. Message-ID: <BuD46B.7Cp@world.std.com>
  6. Organization: GCC Technologies
  7. References: <72240@apple.Apple.COM>
  8. Date: Thu, 10 Sep 1992 12:32:34 GMT
  9. Lines: 43
  10.  
  11. In article <72240@apple.Apple.COM> mkelly@Apple.COM (Michael Kelly) writes:
  12. >
  13. >OK, this is strange.  I had a simple program that first initialized the
  14. >toolbox with InitFonts, etc., in the correct order, and then went on to
  15. >make some File Manager calls.  The initialization routine was in a separate
  16. >file from both main and the rest of the program.  I wasn't including
  17. >MacHeaders in the Prefix.  I ran the program with the debugger, and it
  18. >crashed violently in the toolbox initialization routine.  I tried a few
  19. >things, none of which made any difference.  I finally #included MacHeaders
  20. >at the top of the file, and then it worked.  Weird.
  21. >
  22. >The next call was in a different file.  It was to FSMakeFSSpec, which failed,
  23. >saying the volume didn't exist.  There was nothing wrong with the call.  I
  24. >#included MacHeaders, on a whim, in that file, and magically the function
  25. >worked as it should.
  26. >
  27. >The next call was to OpenWD, in yet another file.  It stopped in the
  28. >debugger with a bus error inside MacTraps2.  "Well, this is silly," I
  29. >thought, and I put MacHeaders in the Prefix.  Now the program works as
  30. >it should (well, except for some other unrelated things....)
  31. >
  32. >So, any ideas?  Has anyone run into this sort of weirdness before?
  33.  
  34. No wierdness at all. All of the calls you've mentioned here are implemented
  35. through glue in an external library (MacTraps and MacTraps2 in this case).
  36. Since you called them with the correct spelling, you didn't get link errors,
  37. but because you didn't include either <MacHeaders> or the appropriate
  38. Toolbox headers (File.h would be appropriate here), the compiler rightly
  39. concluded that the undeclared functions used the C calling convention
  40. and returned an 'int'. Bad news, since all Toolbox calls are 'pascal'
  41. functions. By including <MacHeaders>, you get declarations for all of
  42. the functions whose functions are prototyped in the headers that
  43. MacHeaders was built from, so this doesn't happen.
  44.  
  45. R.
  46.  
  47.  
  48.  
  49. -- 
  50. -----------------------------------------------------------------------
  51. Rich Siegel                              Internet: siegel@world.std.com
  52. Software Engineer & Toolsmith
  53. GCC Technologies
  54.