gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Interrupts

#69035 - n0va - Sat Jan 28, 2006 2:10 am

I'm having problems compiling my code. Whenever I assign something to REG_IRQ_HANDER, like this
Code:
REG_IRQ_HANDLER = IrqHandler
the compiler gives me this
Code:
main.cpp:22: error: assignment of read-only location
main.cpp:22: error: cannot convert 'void ()()' to 'void ()()' in assignment


Can somebody tell me what's going on?

The command I ran is
Code:
arm-elf-g++ main.cpp -o main.o -c -g -Wall -mthumb-interwork
and I'm using DevKitARM. It doesn't seem to work with DevKitAdv anyway.

#69052 - tepples - Sat Jan 28, 2006 4:14 am

n0va wrote:
Whenever I assign something to REG_IRQ_HANDER, like this
Code:
REG_IRQ_HANDLER = IrqHandler
the compiler gives me this
Code:
main.cpp:22: error: assignment of read-only location
main.cpp:22: error: cannot convert 'void ()()' to 'void ()()' in assignment


Hmm, interesting. Are you making sure to use extern "C" on your IRQ handler's prototype?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#69065 - sajiimori - Sat Jan 28, 2006 6:33 am

It seems to suggest that REG_IRQ_HANDER is defined as pointer-to-const.

#69317 - nmain - Mon Jan 30, 2006 12:27 am

I'm not familiar with that symbol, but if it's meant to be defined as the interrupt vector that is at the end of iwram, and trying to assign something to it gives a const error, then it sounds to me like the definition or define is wrong. Track down whatever header that symbol / define is in; and if you can't make sense of it post it here. This is what it should be like, courtesy TONC:

Code:

typedef void (*fnptr)(void);
#define REG_INTMAIN (*(fnptr*) (0x03fffffc))

void my_int_fn (void)
{
  // Col Sandurz:  "Do something!"
}

// in the initialization code
REG_INTMAIN = my_int_fn;