#1 Burning Software

It is currently Thu Dec 19, 2024 10:21 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: cannot convert to 'PCALLBACK', Visual C++ 2005
PostPosted: Thu Jun 14, 2007 3:54 pm 
Offline

Joined: Thu Jun 14, 2007 3:09 pm
Posts: 4
Hi,

recently I have started to test the StarBurn SDK.
It looks good and seems to be adequate for my project.
But, unfortunately I'm stuck with a conversion problem:

error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'PCALLBACK'

The following statement from the FindDevice.c sample is a candidate for this kind of error:

l__LONG__NumberOfCdvdDevices =
StarBurn_FindDevice(
SCSI_DEVICE_RO_DIRECT_ACCESS,
FALSE,
( PCALLBACK )( FindCallback ), // this is the problem
NULL);

My programming environment is Visual C++ 2005.

Any one have a clue how to overcome the probleme?

Regards,

Jens.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 7:06 am 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
The problem has nothing to do with the StarBurn itself rather it's C++ programming issue :) You cannot pass address of the member as getting address need to have static member. This raises another problem - all the member variables touched from static method also need to be static. This cannot always be done. So you should do something like this (little trick):

class CBurner
{
private:
...

protected:
...

public:

static long __stdcall CallbackWrapper( void *context );

virtual long Callback( void *context );

};


long
__stdcall
CBurner::CallbackWapper( void *context )
{
CBurner *burner = ( CBurner * )( contex );

return CBurner->Callback( context );
}


long
CBurner::Callback( void *context )
{
// Do whatever you want to do with the non-static members
}


Now you need to pass CallbackWrapper as the callback address. It's static so casting will not fail. From inside the static code you do cast from void* to "this" (basically) and call virtual method :)

Here we are :)

Let me know did it help or not.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 11:15 am 
Offline

Joined: Thu Jun 14, 2007 3:09 pm
Posts: 4
Dear Anton Kolomyeytsev,


I act the fool. Having a static member is the answer.
Thank you! :D Your wrapper sample was very helpful,
now the test is runnig fine.


Best regards,

Jens.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 12:14 pm 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
Doing our best to keep customers dry and happy :)

jens wrote:
Dear Anton Kolomyeytsev,


I act the fool. Having a static member is the answer.
Thank you! :D Your wrapper sample was very helpful,
now the test is runnig fine.


Best regards,

Jens.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group