[comp.sys.mac.programmer] Can LSC call a Pascal function pointer?

rpd@Apple.COM (Rick Daley) (04/21/89)

OK, everyone knows that you can create a function that follows Pascal
calling conventions by using the "pascal" keyword.  But, what if you
want to declare a pointer to one of these functions and then call it?
I'm using LSC 3.0 and I can't figure out how to do it.  I even resorted
to looking through the manual.

In MPW, I can do this:

typedef pascal long (*routinePtr)(OSErr err, ushort ignoreThis);

But in LSC, I can't get the compiler to accept either the "pascal" keyword
or a parameter list in the typedef.  The only solution I know of is to
call the routine via inline assembler.  What's a poor programmer to do?

						Rick Daley
						rpd@apple.com

siegel@endor.harvard.edu (Rich Siegel) (05/06/89)

In article <1491@internal.Apple.COM> rpd@Apple.COM (Rick Daley) writes:
>OK, everyone knows that you can create a function that follows Pascal
>calling conventions by using the "pascal" keyword.  But, what if you
>want to declare a pointer to one of these functions and then call it?
>I'm using LSC 3.0 and I can't figure out how to do it.  I even resorted
>to looking through the manual.

	There's a family of routines:

		pascal void CallPascal()
		pascal char CallPascalB()
		pascal int  CallPascalW()
		pascal long CallPascalL()

These routines take as their LAST argument a pointer to the Pascal function
to be called. (I believe they are documented, but I don't have my manuals in
front of my, so I'm not sure where...)

		--Rich


~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

 "She told me to make myself comfortable, so I pulled down my pants
 and sat in the pudding." -Emo Phillips
~~~~~~~~~~~~~~~

austing@Apple.COM (Glenn L. Austin) (05/08/89)

In article <1491@internal.Apple.COM> rpd@Apple.COM (Rick Daley) writes:
>OK, everyone knows that you can create a function that follows Pascal
>calling conventions by using the "pascal" keyword.  But, what if you
>want to declare a pointer to one of these functions and then call it?
>I'm using LSC 3.0 and I can't figure out how to do it.  I even resorted
>to looking through the manual.
>
>In MPW, I can do this:
>
>typedef pascal long (*routinePtr)(OSErr err, ushort ignoreThis);
>
>But in LSC, I can't get the compiler to accept either the "pascal" keyword
>or a parameter list in the typedef.  The only solution I know of is to
>call the routine via inline assembler.  What's a poor programmer to do?

What I do is write a front-end caller for LSC which uses a "generic" procedure
definitions for the pascal function pointer, then set the pointer to the value
passed into my call, then make the call.  I haven't had to resort to assembly
to do any of this, it is simply C code (although I admit it is rather ugly).


-----------------------------------------------------------------------------
| Glenn L. Austin             | The nice thing about standards is that      | 
| Apple Computer, Inc.        | there are so many of them to choose from.   | 
| Internet: austing@apple.com |       -Andrew S. Tanenbaum                  |
-----------------------------------------------------------------------------
| All opinions stated above are mine -- who else would want them?           |
-----------------------------------------------------------------------------