Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to compare two function pointers?

215 views
Skip to first unread message

Danffer Liu

unread,
Feb 19, 2002, 8:18:33 AM2/19/02
to
There is a variable ,for example , called A, which is a function pointer.
After some codes, it may be set with some value: func1, func2 or func3 and
so on. I want to know which one has been set. But "if A = func1 then ..."
does not work at all. The compiler does not regard A and func1 as only the
address of some functions.
What shell I do?


Constantine Yannakopoulos

unread,
Feb 19, 2002, 8:49:51 AM2/19/02
to

> so on. I want to know which one has been set. But "if A = func1 then
..."
> does not work at all. The compiler does not regard A and func1 as
only the

I think it is "if @A = @func1".


Ray Cernis

unread,
Feb 19, 2002, 9:21:25 AM2/19/02
to
If they're just function pointers, you can use if @A = @Func1.

It gets a bit trickier if they're method pointers, but if the functions are
published, you can use

if @A = MethodAddress('Func1')

Ray

"Danffer Liu" <danff...@263.net> wrote in message news:3c7250c3_1@dnews...

Ray Cernis

unread,
Feb 19, 2002, 9:51:47 AM2/19/02
to
Definitely better. Nice one.

Ray

"Tomas Särnhammar" <tNomOas.sSa...@spam.iquity.com> wrote in message
news:3c726506_1@dnews...

> Even better is to cast to TMethod and compare the Code parts. This always
> works. See code snip from my current project below:
>
> if (ListView <> nil) and
> Assigned(ListView.OnDblClick) and
> (TMethod(ListView.OnDblClick).Code =
> @TDynamicListItemPopup.DefaultActionExecute) then
>
> rgs
>
> Tomas Särnhammar
>
>
>
>


Tomas Särnhammar

unread,
Feb 19, 2002, 9:48:47 AM2/19/02
to
> It gets a bit trickier if they're method pointers, but if the functions
are
> published, you can use
>
> if @A = MethodAddress('Func1')

Even better is to cast to TMethod and compare the Code parts. This always

0 new messages