www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/12/21/11:50:44

Date: Thu, 21 Dec 1995 15:08:00
From: "Alaric B. Williams" <DJGPP AT abwillms DOT demon DOT co DOT uk>
Reply-To: DJGPP AT abwillms DOT demon DOT co DOT uk
To: denis AT oitunix DOT oit DOT umass DOT edu, DJGPP AT sun DOT soe DOT clarkson DOT edu
Subject: Re: problem running C++ program
Lines: 56

In your message dated Wednesday 20, December 1995 you wrote :
> Hi everyone.  I've been having a problem running a C++ program that I've
> written. It compiles and links with no real problems. When I run it, though,
> I get this...
> Here's the class definition for Int9:
> 
> class Int9: public IntHandler {
>   public:
>     Int9();
>     Buffer<unsigned> KBbuffer;
>     unsigned getkp();
>   protected:
>     virtual void handler();
>     volatile unsigned char keypressed[256];
>   private:
>     volatile unsigned KBcode;
>     volatile unsigned char e0flag, e1counter;
> };
> 
> And here's the class definition for Int9's base class:
> 
> class IntHandler {
>   public:
>     void install();
>     void remove();
>   protected:
>     virtual void handler() = 0;
>     int IRQnumber;    //must be set by derived classes' constructors
>   private:
>     _go32_dpmi_seginfo oldRMint, newRMint, oldPMint, newPMint;
>     _go32_dpmi_registers RMregs;
>     unsigned char installed;        //true if handler()'s installed
> };

Hmmm... are you passing a method to an interrupt handler? That's fatal (or was, 
last time I looked) because a method expects a parameter - not that you ever see 
it - called this, which is a pointer to the object which the method is being 
called in reference to. If you just make a method into an interrupt handler, 
when it's called it'll get some crap on the stack which isn't the expected 
pointer. So any references to things inside the class are failures. Trying to 
call a virtual function would definitely crash.

The solution: create some /static/ interrupt handler functions, which your 
generic object sets a flag to activate, and leaves a pointer to itself 
somewhere, so when the actual handler engages, it passes control to you virtual 
function.

Regards,


ABW

-- 
Alaric B. Williams (alaric AT abwillms DOT demon DOT co DOT uk)
"A man walks into a bar, right, and he goes 'ouch' coz it's an iron bar"

- Raw text -


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