home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!psinntp!cubetech.com!imladris!moebius!peterc
- From: peterc@cubetech.com (Peter Creath)
- Newsgroups: comp.sys.mac.system
- Subject: Re: new Inside Mac : Pascal or C ?
- Date: Fri, 24 Jul 92 21:03:34 CDT
- Organization: Cube Technologies
- Message-ID: <dx3uv972.9c855d@moebius.cubetech.com>
- Reply-To: peterc@cubetech.com
-
- Lines: 45
-
-
- In article <1992Jul22.125412.20240@python.microcom.com> (comp.sys.mac.system), short@microcom.com (Todd Short) writes:
- > The problem of using both C and Pascal is the calling convention! C places the
- > last argument on the stack first, Pascal puts the first argument on first. Also,
- > in C, the caller is supposed to clean up the stack, in Pascal, the callee does
- > this.
-
- Yup.
-
- > If you were able to use straight C in programming a Mac, then Apple would
- > have to modify a lot of system calls.
-
- Yup. Plus, C calls aren't very useful for writing external modules.
- Using Pascal calling conventions, you can:
-
- pascal myFunction(argument1, argument2, ProcAddress) = 4E90;
-
- When your C compiler hits that, it puts the ProcAddress as the last
- item on the stack. The 4E90 (excuse me if I got the opcode wrong)
- does an indirect jump/jsr off the stack. It's very clean and efficient
- in Assembly...
-
- > Windows uses the Pascal structure, and the
- > "keyword" _pascal must be used in C to prototype it. As in:
- >
- > extern far _pascal FunctionToBeCalled(...);
- >
- > Do any Mac C programmer's know if this is true?
-
- Well, it's usually:
-
- pascal long myFunction(...)
- {
- }
-
- as the declaration, or
-
- pascal long myFunction(...);
-
- as the prototype. Then you just call it as a normal function.
-
- ----------------------------------------------------------------------------
- Peter Creath "When I was a boy I was told that anybody could
- peterc@cubetech.com become president; I'm beginning to believe it."
- -- Clarence Darrow
-