Please read the following code:
typedef void (*TimerCallback)(int RequestID_in, void* AdditionalParameter_in);
class MyTimer
{
public:
MyTimer(){}
bool schedule( int Interval_in, TimerCallback TimerCallback_in, void* AdditionalParameter_in)
{
return true;
}
};
namespace
{
template <class T>
void myTimerFunc(int RequestID_in, void* AdditionalParameter_in)
{
MyLogic<T>* pLogic = static_cast<MyLogic<T>*>(AdditionalParameter_in);
if(pLogic)
{
}
}
}
template <class T>
class MyLogic
{
public:
MyLogic(){}
void testMe()
{
MyTimer aTimer;
aTimer.schedule(10, myTimerFunc<T>, this);
}
};
int main()
{
MyLogic<int> myLogic;
myLogic.testMe();
}
I use the VC6 compiler and the compiler throws the following error:
error C2664: "schedule": cannot convert parameter 2 from 'void (int, void *)' to 'void (__cdecl *) (int, void *)' None of the functions with this name in the region match the target type E : \ test \ BTest \ BTest.cpp (46): when compiling a member of the template class, the function 'void __thiscall MyLogic :: TestMe (are canceled)
I tested this code in Visual Studio 2008 and it works great without any problems.
I know that VC6 is an outdated compiler, but the source code for the project (legacy) is still compiled with VC6.
Therefore, any work around a possible compilation of this code?