opensubscriber
   Find in this group all groups
 
Unknown more information…

m : macpascal@listman.sonic.net 22 July 2005 • 12:04PM -0400

Re: [MacPascal] New interface problem II
by Jonas Maebe

REPLY TO AUTHOR
 
REPLY TO GROUP





On 22 jul 2005, at 17:54, Michael Casteel wrote:

>>> function HandleAEquit  (const quitAppleEvent: AppleEvent; var reply:
>>> AppleEvent; handlerRefCon: LongInt): OSErr; MWPascal;
>>
>> The interface for an AE handler should be:
>>
>> function Handler( const event: AppleEvent;
>> var reply: AppleEvent; refcon: SInt32 ): OSErr;
>
> Except that Free Pascal requires the 'MWPascal' tag (instead of the
> 'stdcall' tag), so changing the var to const is not sufficient. I  
> had to
> change the 'stdcall' tag to the 'MWPascal' tag as well.
>
> This was a lesson in 'const', which I had never seen or used before.

This is a quite annoying side-effect of the different calling  
conventions used by different Pascal compilers under Mac OS X :( I  
wanted to standardise on following C, but there was heavy opposition  
to that. The end result is that there are now at least three  
different calling conventions for const (C, Metrowerks, GPC, FPC).

Metrowerks is simplest: every record declared as "const" is passed by  
reference.

For efficiency reasons, FPC and GPC pass const records up to a  
certain size by value and then by reference (slightly different size  
limits).

C passes everything by value.

You can add

{$calling mwpascal}

at the top of your source to make the Metrowerks calling convention  
the default for that unit/program.


Question to the GPC developers: does GPC now also require a calling  
convention modifier for such procedures, since its default calling  
convention does not match that of Metrowerks either?



Jonas
_______________________________________________
MacPascal mailing list
MacPascal@list...
http://lists.sonic.net/mailman/listinfo/macpascal

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.