[fpc-devel] C library header - var vs pointer for function arguments

Michael Van Canneyt michael at freepascal.org
Thu Aug 4 07:40:13 CEST 2022

On Thu, 4 Aug 2022, gabor via fpc-devel wrote:

> I'd like to provide some fixes for packages that are headers for c 
> libraries. When and should I use the "var" argument for function 
> arguments that return a value, or should I always use pointers 
> (excluding arguments that might accept nil)?
> Eg:
> function Foo(var A: Integer): Integer;
> vs
> function Foo(A: PInteger): Integer;

It's best to use pointers, but you can always provide overloads with var

And as Dmitry Boyarintsev pointed out, don't change existing signatures for
backwards compatibility.


More information about the fpc-devel mailing list