Hello,
I need to make an SDL Thread that performs a matrix multiplication. The matrix class I wrote is templated so I can store any type of data in it. From what I understand of SDL Threads, you have to use a struct to pass parameters to the thread, so I'm doing this:
1 2 3 4
|
struct parameters{
Matrix<T> m1;
Matrix<T> m2;
};
|
And create the thread like this:
1 2 3 4
|
parameters<T> thrd1;
thrd1.m1 = matrix1;
thrd1.m2 = matrix2;
thread = SDL_CreateThread( TestThread, &thrd1 );
|
With the threaded function like this:
1 2 3 4
|
int TestThread( void *data )
{
return 0;
}
|
This compiles, but the problem is that if I want to reinterpret and create a matrix in the thread function, it needs to be templated, so I do this:
1 2 3 4 5 6
|
template <class T>
int TestThread( void *data )
{
Matrix<T> m1 = (reinterpret_cast<parameters<T>*>(data));
return 0;
}
|
But that gives me this error:
error C2664: 'SDL_CreateThread' : cannot convert parameter 1 from 'int (__cdecl *)(void *)' to 'int (__cdecl *)(void *)'
And I have no idea why. How can you not convert a parameter of the same type you're trying to convert to? The problem is with the "template <class T>", because if I take that out and give parameters a type like int rather than a template T, it compiles.
Can anyone please help?