>>> 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
For efficiency reasons, FPC and GPC pass const records up to a
certain size by value and then by reference (slightly different size
C passes everything by value.
You can add
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?