delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/17/20:01:40

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro Timers
Date: Fri, 17 Jan 1997 19:55:02 +0000
Organization: None
Lines: 28
Distribution: world
Message-ID: <5DP9XEAWk93yEwfW@talula.demon.co.uk>
References: <fgtLCdAvIM3yEwIZ AT flag DOT demon DOT co DOT uk>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Moo-Juice writes:
>I've been having some trouble installing timers in Allegro, using a
>public class member function as the argument.
>
>Supplying a standard function as the parameter works, but if I pass a
>class member function it doesn't like it at all.  Is there a work around
>for this?

Not easily. C++ class members take a 'hidden' parameter which is a
pointer to the object, so calling class.member() is really the same as
writing member(&class) in C. Allegro has no way of knowing about this
hidden parameter, so the call won't work.

The easy workaround is to make the member function static, so it won't
have the hidden parameter. Alternatively, write a wrapper function to
use as the timer callback, eg:

class myobject;

void wrapper()
{
        myobject.member();
}

/*
 *  Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
 *  Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
 */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019