From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: Passing functions as a parameter in C++ Date: 30 May 2000 10:41:55 GMT Organization: Aachen University of Technology (RWTH) Lines: 30 Message-ID: <8h05tj$gio$1@nets3.rz.RWTH-Aachen.DE> References: <8gukef$c21$18$1 AT news DOT t-online DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 959683315 16984 137.226.32.75 (30 May 2000 10:41:55 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 30 May 2000 10:41:55 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Raul Carolus wrote: > Ok, i'm about to blow my computer up over this problem. > I have a nice little function: > void TimerUpdate() { GlobalTime++; } > all set up to hook to a timer. I'm using Allegro and the MIDAS sound > library in my > project. Since Midas doesn't like to work with Allegro's timer functions, > i'm using one of midas's: > MIDASsetTimerCallback(int, bool, void*, void*, void*); > The three void*'s are functions. Thats extremely bad programming style on the side of MIDAS. Even in C, you are not allowed to call a function through a pointer that has been casted to 'void *', before it's used. You invoke undefined behaviour that way. C++, because of its polymorphism support and its consequences, is even stricter than C, here. > So, my problem is, I really would like to use this, but it seems to not like > C++ very much. Can someone aid me in resolving my problem? Have you checked whether the MIDAS prototype for MIDASSetTimerCallback() is contained in an 'extern "C" { }' block? If it isn't, you should add one. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.