[fpc-devel] QueryInterface on linux/i386 - adding 'in' parameter type?
Joost van der Sluis
joost at cnoc.nl
Sat Aug 28 14:54:48 CEST 2010
On Sat, 2010-08-28 at 14:39 +0200, Jonas Maebe wrote:
> 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".
I would say 'constref'. But what do you thing of the idea from Marco to
use a directive? It will avoid problems with Delphi-compatibility.
http://www.hu.freepascal.org/fpcircbot/cgifpcbot?channel=fpc&fromdate=2010-08-28&todate=2010-08-28&linecount=50&fromtime=14%3A20&totime=15%3A00&sender=&msg=
> > 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).
Hey, that's the easiest for me, now. No need to change the compiler. But
i'm not sure that this is the best solution for the long run.
Joost.
More information about the fpc-devel
mailing list