BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pointers to functions

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
JD
Guest





PostPosted: Tue Mar 22, 2005 5:32 am    Post subject: Pointers to functions Reply with quote




I want to build a list of pointers to functions but I can't
resolve the compiler errors:

AddFunction( &FunctionName );

The above produces two errors:

Cannot convert 'void (_fastcall * (_closure )(AParam &))(AParam &)'
to 'void (_fastcall * (_closure *)(AParam &) *)(AParm &)'

Type mismatch in parameter 1
wanted 'void (_fastcall * (_closure *)(AParam &) *)(AParam &)',
got 'void (_fastcall * (_closure )(AParam &))(AParam &)'


typedef void __fastcall (__closure *Function)( AParam& );

void AddFunction( TFunction Function )
{
if( List->IndexOf(Function) < 0 )
{
List->Add( Function );
}
}

Now I'm also thinking that the typedef does not resolve to 4
bytes anyway. Can I do this?

~ JD

Back to top
Liz Albin
Guest





PostPosted: Tue Mar 22, 2005 6:31 am    Post subject: Re: Pointers to functions Reply with quote



On 21 Mar 2005 21:32:29 -0800, JD wrote:

Quote:
I want to build a list of pointers to functions but I can't
resolve the compiler errors:

Are the functions in question method pointers? it makes a difference
--
Good luck,

liz

Back to top
Thomas Maeder [TeamB]
Guest





PostPosted: Tue Mar 22, 2005 6:31 am    Post subject: Re: Pointers to functions Reply with quote



"JD" <nospam (AT) nospam (DOT) com> writes:

First of all:

You are writing about pointers to functions in the subject and part of
your post. But your code is using closures. Please note that the two
are quite different beasts, even if they usually serve similar
purposes.

Which one is it that you want?


Quote:
I want to build a list of pointers to functions but I can't
resolve the compiler errors:

AddFunction( &FunctionName );

The above produces two errors:

Cannot convert 'void (_fastcall * (_closure )(AParam &))(AParam &)'
to 'void (_fastcall * (_closure *)(AParam &) *)(AParm &)'

Type mismatch in parameter 1
wanted 'void (_fastcall * (_closure *)(AParam &) *)(AParam &)',
got 'void (_fastcall * (_closure )(AParam &))(AParam &)'


typedef void __fastcall (__closure *Function)( AParam& );

void AddFunction( TFunction Function )
{
if( List->IndexOf(Function) < 0 )
{
List->Add( Function );
}
}

Please post the minimal program that lets us see what you are
seeing. That would (in this case) be more code than you have posted
here; just enough that we can cause our compilers to spit out the
error messages you are seeing.


Quote:
Now I'm also thinking that the typedef does not resolve to 4
bytes anyway.

I don't know what you mean, but numbers of bytes are very unlikely to
be the issue here.


Quote:
Can I do this?

Can you do what?

Back to top
JD
Guest





PostPosted: Tue Mar 22, 2005 7:32 am    Post subject: Re: Pointers to functions Reply with quote


[email]maeder (AT) glue (DOT) ch[/email] (Thomas Maeder [TeamB]) wrote:
Quote:

[...] Please post the minimal program that lets us see what
you are seeing. [...]

LOL. Thanks for that. I found the problem:

void __fastcall RegisterFunction( TUpdateFunction* );

has been changed to:

void __fastcall RegisterFunction( TUpdateFunction );

and now the error messages make perfect sense to me <g>.

~ JD


Back to top
JD
Guest





PostPosted: Tue Mar 22, 2005 7:34 am    Post subject: Re: Pointers to functions Reply with quote


Liz Albin <lizalbin (AT) yahooNotThis (DOT) com> wrote:
Quote:

Are the functions in question method pointers? it makes a
difference

It was a type-o. How unusual!!! <g>

~ JD


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.