[comp.sys.mac.programmer] MPW->Think C typedef pascal ...

bernard@boulder.colorado.edu (Bernie Bernstein) (01/30/91)

How does one map the following typedef from MPW to Think C?

typedef pascal void (*myfunction)(short *a, char *b);

The compiler says "Invalid Storage Class" unless I remove the "pascal"
part.

I assume the pascal part is important because I use this type to
extract functions from resources which use pascal conventions.

Bernie Bernstein
bernard@boulder.colorado.edu
bernardb@applelink.apple.com

phils@chaos.chaos.cs.brandeis.edu (Phil Shapiro) (02/02/91)

In article <1991Jan30.002237.18618@csn.org> bernard@boulder.colorado.edu (Bernie Bernstein) writes:
   How does one map the following typedef from MPW to Think C?

   typedef pascal void (*myfunction)(short *a, char *b);

   The compiler says "Invalid Storage Class" unless I remove the "pascal"
   part.

   I assume the pascal part is important because I use this type to
   extract functions from resources which use pascal conventions.

The current version of Think C (v4.02) is very dumb about function
pointers.  It doesn't know about function pointer argument lists, and
it also can't distinguish between "pascal" and "C" -typed functions.
The reason ThC complained about the "storage class" is because ThC
treats "pascal" as a storage class, like "static" or "auto".

The moral to this story is:  unless you're calling a function through
a function pointer, you can always use ProcPtr.  The only thing that
ThC checks is the function's return type, so you may need different
function pointers for this purpose.

If you're calling a function through a function pointer, then you'll
have to use CallPascal(), unless it's a C-style function pointer.

	-phil
--
   Phil Shapiro                           Technical Support Analyst
   Language Products Group                     Symantec Corporation
		Internet: phils@chaos.cs.brandeis.edu