[fpc-pascal] Re: Passing objects to libraries and back

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Feb 27 11:19:15 CET 2011


On 27 Feb 2011, at 09:58, leledumbo wrote:

> Read the docs. If the size of the argument is greater than native pointer
> size, it would be passed by reference.

If the docs say that somewhere, they are wrong. How a "const" parameter is passed is an implementation detail (which hence could change at any time), except for "stdcall" routines on Windows platforms (for COM compatibility).

The only thing 'const' means is that the programmer tells to the compiler that this parameter will not change inside the called routine (if it nevertheless does, the generated code may be invalid). Based on that information, the compiler can perform additional checks (catching direct assignments to the parameter inside the routine) and optimizations (passing it by value/reference depending on the size and target platform, not performing reference count adjustments, ...).


Jonas


More information about the fpc-pascal mailing list