Message Edited by CaffineCoder on 2007-03-0710:07 PM
Message Edited by CaffineCoder on 2007-03-0710:16 PM
Message Edited by Alban on 2007-03-08 09:11 AM
as far a can i tell it is FCALL's fault but how to get around it is beyond me at this time
void __far _FCALL(void) {
__asm {
LDY 1, SP ; A B C D E F Y = B C ; 2 bytes
MOVW 3, SP, 1, SP ; A D E D E F Y = B C ; 4 bytes
MOVB 0, SP, 3, SP ; A D E A E F Y = B C ; 4 bytes
MOVB 5, SP, 0, SP ; F D E A E F Y = B C ; 4 bytes
STY 4, SP ; F D E D B C Y = B C ; 2 bytes
; F D E A B C ;16 bytes
RTC ; call function pointer
}
}
class Foo; //fwd declaration
typedef unsigned int UINT16;
typedef void (Foo::*Callback)(UINT16);
class Foo //declaration proper
{
public:
Foo();
Callback CB;
void somefunction();
void somethingelse();
void func(UINT16);
static Foo foo;
};
Foo Foo::foo;
Foo::Foo()
{
func(7); //dummy call to stop compiler "optimising" function out
}
void Foo::somefunction()
{
CB = &Foo::func; //assign addr
}
void Foo::somethingelse()
{
this->*CB(7); //call with param ?
}
void Foo::func(UINT16 seven)
{
while (seven != 7) { }// wait here if not 7
}
void main(void) {
/* put your own code here */
Foo::foo.somefunction();
Foo::foo.somethingelse();
for(;;) {} /* wait forever */
}
CaffineCoder wrote:i hate to disagree with a Guru but i am going to anyway...
after taking all the callback funtions out of the class and making the callback var static it works perfectly,
so i still believe that there is a problem with class member function pointers.
i did a test with other compilers and the operated perfectly with both sets of code member function pointers and global.maybe you didnt experience the problem because of compiler settings differences?