Trouble with SDL_AddTimer()

Hi, all.
I have a class (yes this is c++) with two functions whose prototypes are like
this:
Uint32 Display::dimAll(Uint32 interval, void* param);
void Display::fadeBlack(Uint32 millis);

Inside fadeBlack, when I call this:
SDL_TimerID timer = SDL_AddTimer(30, dimAll, amount);
(Where “amount” is the parameter for dimAll(), of type Uint8)

The compiler gives me this:
Display.cpp: In member function void Display::fadeBlack(unsigned int)': Display.cpp:173: no matches converting functiondimAll’ to type `Uint32
()(unsigned int, void)'
Display.h:37: candidates are: Uint32 Display::dimAll(unsigned int, void*)

My question is, what more do I have to do dimAll’s declaration to make
SDL_AddTimer accept it? I’ve tried giving it return type
SDL_NewTimerCallback, but that doesn’t help–
Max Bane
Kerr’s Three Rules for a Successful College:
Have plenty of football for the alumni, sex for the students,
and parking for the faculty.

Max Bane wrote:

The compiler gives me this:
Display.cpp: In member function void Display::fadeBlack(unsigned int)': Display.cpp:173: no matches converting functiondimAll’ to
type `Uint32 ()(unsigned int, void)'
Display.h:37: candidates are: Uint32 Display::dimAll(unsigned int,
void*)

My question is, what more do I have to do dimAll’s declaration to make
SDL_AddTimer accept it? I’ve tried giving it return type
SDL_NewTimerCallback, but that doesn’t help

Member functions are not the same as normal functions, in that they have
an implicit ‘this’ parameter specifying which object is to be operated
upon. The usual workaround for this sort of thing is to have a static
member function (which -is- like a normal C function) that will cast
your void* or whatever into a pointer to a class instance, and call the
member function on that pointer.–
Kylotan
http://pages.eidosnet.co.uk/kylotan

Member functions are not the same as normal functions, in that they have
an implicit ‘this’ parameter specifying which object is to be operated
upon. The usual workaround for this sort of thing is to have a static
member function (which -is- like a normal C function) that will cast
your void* or whatever into a pointer to a class instance, and call the
member function on that pointer.

Yes, this explanation makes perfect sense – I just wish that the compiler
error message would show the “hidden” ‘this’ argument in function signatures,
making it easier to spot what doesn’t match up. I’m forgetful, and this
probably isn’t the last time it’ll bite me in the bum :slight_smile: .
The solution also seems sound. Thanks a lot.On Monday 14 April 2003 10:30 pm, Kylotan wrote:


Max Bane
Have you noticed that all you need to grow healthy, vigorous grass is a
crack in your sidewalk?