[SDL] [Need help] Why this code crached?
David Olofson
david at olofson.net
Sat Jan 20 13:57:28 PST 2007
On Saturday 20 January 2007 22:07, Mike Shal wrote:
> On 1/20/07, David Olofson <david at olofson.net> wrote:
> > 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().
>
> I don't think this is the problem - he's using a static member
> function as the callback, which doesn't have a 'this' pointer. And
> he's only using static data in audio_callback(), so he doesn't need
> to do the typical casting of userdata that you would expect.
[...]
Yes, you're right, of course. Wasn't reading carefully enough...
Also, one would expect to get compile errors, or at least warnings if
trying to pass a non static member.
//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