Subject Re: [firebird-support] How to declare a UDF function in Delphi (cdecl
Author Adriano dos Santos Fernandes
Milan Babuskov escreveu:
> Hi Carlos,
>
> Carlos H. Cantu (TeamFB) wrote:
>> I> Can somebody help and say what is the right kind of declaration?
>>
>> Copying Dmitry Yemanov words:
>>
>> Unlike what the original IB documentation says, the calling convention
>> should be "cdecl" instead of "stdcall".
>
> any more info on why 'cdecl' should be used?
>
stdcall functions restore the stack while cdecl functions leave this
task to the caller. You cannot have stdcall function with variable
number of parameters.

FB calls the UDF passing the max number of allowed parameters, and not
only the number of parameters declared. Otherwise it would need
hardcoded calls to function with 1, 2, 3, etc number of parameters or
generate assembly on the fly.


Adriano