From: Martynas Kunigelis Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro Timers Date: Sat, 18 Jan 1997 13:32:41 +0000 Organization: LITNET Lines: 47 Message-ID: References: <5DP9XEAWk93yEwfW AT talula DOT demon DOT co DOT uk> NNTP-Posting-Host: santaka.sc-uni.ktu.lt Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <5DP9XEAWk93yEwfW@talula.demon.co.uk> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On Fri, 17 Jan 1997, Shawn Hargreaves wrote: > > 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, what if you want to set many callbacks? Writing 'many' wrappers is not a reasonable solution. A good solution IMHO would be if the SetCallback or whatever function took a parameter void *UserData, and then pass this parameter to the callback handler. Then you could pass the address of the object when setting the callback and the wrapper would look like this: void wrapper(void *data) { ((myclass *)data)->member(); } and you would be able to have one wrapper for many objects, and make it a static member function actually. I know this implies changing the API, but that's just a theoretical suggestion and you might consider it doing further development. P.S. I can't wait for Linux-GGI (General Graphics Interface) to show up, so a port of Allegro to Linux would be possible! Martynas