[fpc-pascal] Question about functions returning a string

Flávio Etrusco flavio.etrusco at gmail.com
Sat Nov 29 00:41:17 CET 2014


On Fri, Nov 28, 2014 at 5:54 PM, Ewald <ewald at yellowcouch.org> wrote:
> Hi,
>
> Take the following function prototype (in {$mode objfpc}{$H+} for the
> record):
>
>     Function SomeFunction(const Data: PChar; const Len: LongWord):
> String; cdecl; public;
>
> Looking at the dissasembly of this function, I see that is actually has
> three arguments. It looks more like this from an assembler perspective:
>
>     Function SomeFunction(HiddenArgument: Pointer; const Data: PChar;
> const Len: LongWord): String; cdecl; public;
>
> Which is, well, quite fascinating really. What is it doing there? I
> suspect it has something to do with the result type of the function,
> being a string?
>
> Can anybody shed some light on this?
>
> --
> Ewald

Are you sure it's not the result that is passed in the first parameter?

http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl

Best regards,
Flávio



More information about the fpc-pascal mailing list