[SDL] [Need help] Why this code crached?
David Olofson
david at olofson.net
Sat Jan 20 14:02:37 PST 2007
On Saturday 20 January 2007 21:57, Igor Mironchick wrote:
> 2007/1/20, David Olofson <david at olofson.net>:
> >
> > On Saturday 20 January 2007 21:07, Igor Mironchick wrote:
> > [...]
> > > static void audio_callback( void *userdata, Uint8 *stream,
> > > int [...] len );
> > [...]
> >
> > You can't pass this function as a C callback! It needs
> > an "invisible" 'this' argument to work.
> >
> > You need to use a C calling convension wrapper callback, that
> > casts 'userdata' to the type of your class, and then forwards the
> > call to your audio_callback().
>
>
> Ooops, and where I can read about "C calling convension wrapper
> callback"?
I think this has been discussed a few times in the past. It's a
standard solution for wiring C API callbacks to non static C++ class
members. Handy when you need to keep track of multiple instances of
things in a mixed C/C++ system.
Either way, as you're using a static member here, this shouldn't be an
issue. I should learn to read. :-D
//David Olofson - Programmer, Composer, Open Source Advocate
.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
'-- http://www.reologica.se - Rheology instrumentation --'
More information about the SDL
mailing list