[fpc-devel] QueryInterface on linux/i386 - adding 'in' parameter type?

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Aug 28 14:39:16 CEST 2010

On 28 Aug 2010, at 13:59, Joost van der Sluis wrote:

> Now I see three options: pass all records with a size bigger then the
> register-size by reference for all cdecl-params which are defined as
> 'const'. The same happens for stdcall parameters on Windows and this is
> suggested before by some people. This should not lead to any backwards
> compatibility problems, because when 'const' is used right, it leaves
> the decision to pass by reference or not to the compiler. So when this
> changes, there shoudn't be any problem. 

That's not true for cdecl. For cdecl, "const" means "pass the same way as if it was declared as 'const' in C".

> This leads to the third option: introduce a new parameter-type which
> will always pass the variable by reference, and will be handled as being
> constant by the compiler. We could name it 'in', for example.

"in" is not a good name, it does not convey any information to the reader about how the parameter is passed (and since the whole point of introducing such a modifier is changing the way the parameter is passed...). Past suggestions have included "const var" (http://bugs.freepascal.org/view.php?id=7612), "constvar" and "constref".

> First and third option are possible. I would choose for the third option
> because this will also settle these kind of problems for the future.
> (This idea is also mentioned on this list before by others)
> Or are there any considerations/arguments that I missed?

Another option is to declare it as "mwpascal" instead of "cdecl". The mwpascal calling convention is identical to cdecl, except that all structured const parameters are passed by reference (for compatibility with the MetroWerks Pascal compiler).


More information about the fpc-devel mailing list