Difficulty porting SMPEG player's "update" from C to C++
Doru-Catalin Togea
doru-cat at ifi.uio.no
Thu May 22 04:26:50 EDT 2003
Hi!
I am runing RedHat 7.3 with gcc 2.96.
I am trying to port the SMPEG player from C to C++, and I have a problem
which I do not understand, while porting the very "simple" update(...)
function:
The C programme is like this:
==================================================================
#include ...
// the function I have problems with:
void update(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
{
if ( screen->flags & SDL_DOUBLEBUF ) {
SDL_Flip(screen);
}
}
main(int argc, char *argv[])
{
...
if ( info.has_video && use_video ) {
...
SMPEG_setdisplay(mpeg, screen, NULL, update); // update called here
// by referance
}
...
}
==================================================================
In my C++ programme I have a class declared as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class MPEGPlayer : public Module {
private:
...
// cut-and-paste from the C programme
void update(SDL_Surface *screen,
Sint32 x, Sint32 y, Uint32 w, Uint32 h);
// the C'programme's main routine's code
// will be run here:
static void *playMPEG (void *threadArgs);
public:
...
};
void MPEGPlayer::update(SDL_Surface *screen,
Sint32 x, Sint32 y, Uint32 w, Uint32 h)
{
if ( screen->flags & SDL_DOUBLEBUF ) {
SDL_Flip(screen);
}
}
// basically the same code as the C programme's main routine:
void *MPEGPlayer::playMPEG(void *threadArgs)
{
...
if ( info.has_video && use_video ) {
...
SMPEG_setdisplay(mpeg, screen, NULL, update); // update called here
// by referance
}
...
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I try to compile my C++ programme (which uses the MPEGPlayer class) with
the following command:
[...]$ g++ `sdl-config --cflags --libs`
-I/usr/include/smpeg/ -lsmpeg -lSDL -o receiver receiver.cpp
I get the following error message:
In file included from receiver.cpp:10:
mpegPlayer.h: In function `void *MPEGPlayer::playMPEG (void *)':
mpegPlayer.h:385: no matches converting function `update' to type `void
(*) (struct SDL_Surface *, int, int, unsigned int, unsigned int)'
mpegPlayer.h:219: candidates are: void MPEGPlayer::update (SDL_Surface
*, int, int, unsigned int, unsigned int)
Can anyone tell me what I am doing wrong?
Thanks a lot,
Catalin
--
<<<< ================================== >>>>
<< We are what we repeatedly do. >>
<< Excellence, therefore, is not an act >>
<< but a habit. >>
<<<< ================================== >>>>
More information about the smpeg
mailing list