From: Martynas Kunigelis Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro Timers Date: Thu, 16 Jan 1997 18:31:13 +0000 Organization: LITNET Lines: 59 Message-ID: References: NNTP-Posting-Host: santaka.sc-uni.ktu.lt Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On Wed, 15 Jan 1997, Moo-Juice wrote: > Hi, > > 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? > Because a member function has a hidden parameter -- the 'this' pointer. In C world, a Object.Member(int parameter) looks like ObjectMember(Class *this, int parameter), while Allegro wants a function that takes integer only (dunno the exact case, this is an example only). You must use a static member function for that, but Allegro should provide some kind of user data parameter for the callback, so you could pass the 'this' pointer explicitly, e.g. (note I've never used allegro): class thingy { private: static void timerCallback(int timeout, void *object) { ((thingy *) object)->handleTimerCallback(timeout); } void handleTimerCallback(int timeout) { // the actual code.. } }; void allegro_set_timer_callback(int a, int b, fnptr callback, void *userdata); main() { .... thingy myThingy; allegro_set_timer_callback(xx, yy, myThingy.timerCallback, &myThingy); } now, I don't know if Allegro provides the user data parameter for callbacks, but most C frameworks do, and mostly just for situations like yours, i.e. possibility to build C++ wrappers. P.S. good luck to all DJGPPers, it's great. Martynas