[fpc-devel] Local procedures as procedural parameter

Peter Vreman peter at freepascal.org
Thu Mar 17 07:40:00 CET 2005

> 05-03-16 23.08, skrev Peter Vreman följande:
>> But the framepointer parameter must then be the last. That will make
>> macpas  local procedures incompatible with the current code where it is
>> passed as the first parameter.
> Couldn't the framepointer be last parameter in all modes ?

That will break existing code and be incompatible with delphi.

>> Things like the objects unit and FreeVision
>> will then be unusable, without the compiler being able to warn/error you
>> for that.
> Why ? Are these special ?

They have special routines to call local procedures and therefor expect
that the framepointer is the first parameter.

>> Also generating code for cdecl on x86 will become more complex:
>> push para1
>> ..
>> push paraX
>> if isoprocvar.framepointer<>nil then
>> push parentfp
>> call proc
>> dec stack,parasize_on_the_stack-sizeof(parentfp)
>> if isoprocvar.framepointer<>nil then
>> dec stack sizeof(parentfp)
> But cdecl does not allow local functions at all, no ?
> You dont have local functions in C, no ?

The compiler and also delphi accepts it and generates correct code. A
quick 'fix' for this will then be to disallow cdecl in macpas mode.

More information about the fpc-devel mailing list