home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / system / 10397 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  1.9 KB

  1. Path: sparky!uunet!psinntp!cubetech.com!imladris!moebius!peterc
  2. From: peterc@cubetech.com (Peter Creath)
  3. Newsgroups: comp.sys.mac.system
  4. Subject: Re: new Inside Mac : Pascal or C ?
  5. Date: Fri, 24 Jul 92 21:03:34 CDT
  6. Organization: Cube Technologies
  7. Message-ID: <dx3uv972.9c855d@moebius.cubetech.com>
  8. Reply-To: peterc@cubetech.com
  9.             
  10. Lines: 45
  11.  
  12.  
  13. In article <1992Jul22.125412.20240@python.microcom.com> (comp.sys.mac.system), short@microcom.com (Todd Short) writes:
  14. > The problem of using both C and Pascal is the calling convention! C places the
  15. > last argument on the stack first, Pascal puts the first argument on first. Also, 
  16. > in C, the caller is supposed to clean up the stack, in Pascal, the callee does
  17. > this.
  18.  
  19. Yup.
  20.  
  21. > If you were able to use straight C in programming a Mac, then Apple would
  22. > have to modify a lot of system calls.
  23.  
  24. Yup.  Plus, C calls aren't very useful for writing external modules.
  25. Using Pascal calling conventions, you can:
  26.  
  27. pascal myFunction(argument1, argument2, ProcAddress) = 4E90;
  28.  
  29. When your C compiler hits that, it puts the ProcAddress as the last
  30. item on the stack.  The 4E90 (excuse me if I got the opcode wrong)
  31. does an indirect jump/jsr off the stack.  It's very clean and efficient
  32. in Assembly...
  33.  
  34. > Windows uses the Pascal structure, and the
  35. > "keyword" _pascal must be used in C to prototype it.  As in:
  36. >     extern far _pascal FunctionToBeCalled(...);
  37. >
  38. > Do any Mac C programmer's know if this is true?
  39.  
  40. Well, it's usually:
  41.  
  42. pascal long myFunction(...)
  43. {
  44. }
  45.  
  46. as the declaration, or
  47.  
  48. pascal long myFunction(...);
  49.  
  50. as the prototype.  Then you just call it as a normal function.
  51.  
  52. ----------------------------------------------------------------------------
  53. Peter Creath                 "When I was a boy I was told that anybody could
  54. peterc@cubetech.com           become president; I'm beginning to believe it."
  55.                                                            -- Clarence Darrow
  56.