Help whith __closure

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Help whith __closure

Postby Bassin » Tue Nov 23, 2004 5:57 pm

I ´m getting this error message and I don't know what do
the message is:
[C++ Error] Fresa.cpp(328): E2034 Cannot convert 'void (_fastcall * (_closure )(double,double))(double,double)' to 'void (*)(double,double)'

[C++ Error] Fresa.cpp(328): E2342 Type mismatch in parameter 'pt' (wanted 'void (*)(double,double)', got 'void')

if someone can help I will be very gratefull
Bassin
 

Postby Guest » Fri Jan 21, 2005 4:12 pm

Hi Bassin,

Looks like you are trying to assign a pointer to a void function(double, double) to point to the address of a member function of a BCB class. You have not provided any code, so my guess is you have something like:

typedef void (*PTR_FUNCTION)(double, double);
PTR_FUNCTION ptrFunction;
...
void __fastcall Fresa::SomeMethod(double d1, double d2)
{
// Method has some code here...
}
...
void SomeFunction(double d1, double d2)
{
// Function has some code here...
}
...
// This will cause your error:
ptrFunction = &SomeMethod;

If what you are after is a pointer to a member function, Borland provides the magical "__closure" keyword that makes life easy. You could try the following:

typedef void __fastcall (__closure *PTR_MEMBERFUNCTION)(double, double);

PTR_MEMBERFUNCTION ptrMemberFunction;
...
...
ptrMemberFunction = &SomeMethod;
ptrMemberFunction(123.456, 789.012);

Hope that this helps.

Regards,
SydDel.
Guest
 

Function Pointers

Postby Brent Knigge » Thu Jan 27, 2005 5:54 pm

Not sure if it will help your situation, but this article will give you a basic overview of function pointers and their use in the VCL

http://bcbjournal.org/articles/vol4/000 ... inters.htm
Brent Knigge
 


Return to Technical

Who is online

Users browsing this forum: No registered users and 18 guests

cron