[Lazarus] Buffer dealocating between program and C++ library
Leonardo M. Ramé
l.rame at griensu.com
Thu May 12 13:47:43 CEST 2011
On 2011-05-12 05:38:53 +0300, Kostas Michalopoulos wrote:
> I think that using a "@" before the function pointer variable returns the
> variable's address not the function's and that the "@" is needed only for
> functions, ie.
>
> function Foo: TBar;
>
> ...
>
> FooRef:=@Foo;
>
> will assign to FooRef the address of Foo, but
>
> OtherFooRef:=@FooRef;
>
> will try to assign to OtherFooRef the address of the FooRef variable (not
> the address stored in the FooRef variable - that is, the address of Foo) but
> fail at compilation time since OtherFooRef is supposed to be of type of
> whatever Foo is, not a pointer to that type.
>
> However if you just check for nil this won't be noticed since by typing
>
> if @FooRef <> nil ...
>
> is like saying "if FooRef's address is not nil" instead of "if the address
> stored in FooRef is not nil". So basically you need to get rid of those
> "@"s.
>
> Also personally i prefer to use the Assigned built-in function like
>
> if Assigned(FooRef) ...
>
> instead of
>
> if FooRef <> nil ...
>
Thanks. Fixed.
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
More information about the Lazarus
mailing list