What you're doing should work fine. I suspect something else is going on in
the omitted code. Try boiling it down to the minimum.
"Braden MacDonald" <bradenm_k shaw.ca> wrote in message
news:c91951$i1s$1 digitaldaemon.com...

Hi Everyone,
How can I access the memory address of a function? I want the
address for
loading into an Interrupt Descriptor Table.
example :
void
enableInterrupts( ... ) {
...
tables[14].handler=cast(void*)&_interrupt14;
// This generates an error - e2ir: cannot cast from void delegate() to

What you're doing should work fine. I suspect something else is going on in
the omitted code. Try boiling it down to the minimum.
"Braden MacDonald" <bradenm_k shaw.ca> wrote in message
news:c91951$i1s$1 digitaldaemon.com...

Hi Everyone,
How can I access the memory address of a function? I want the
address for
loading into an Interrupt Descriptor Table.
example :
void
enableInterrupts( ... ) {
...
tables[14].handler=cast(void*)&_interrupt14;
// This generates an error - e2ir: cannot cast from void delegate() to

handling page faults when PG (CR0, Paging, bit 31) is set. The processor stores
in CR2 the linear address that triggers the fault." Since I don't see CR0 bit 31
being set in your above code...maybe that's it. ;)

What you're doing should work fine. I suspect something else is going on in
the omitted code. Try boiling it down to the minimum.
"Braden MacDonald" <bradenm_k shaw.ca> wrote in message
news:c91951$i1s$1 digitaldaemon.com...

Hi Everyone,
How can I access the memory address of a function? I want the
address for
loading into an Interrupt Descriptor Table.
example :
void
enableInterrupts( ... ) {
...
tables[14].handler=cast(void*)&_interrupt14;
// This generates an error - e2ir: cannot cast from void delegate() to

Post1: Braden, I'm looking at the Intel 386 Asm Manual, and it states, "CR2 is
used for handling page faults when PG (CR0, Paging, bit 31) is set. The
processor stores in CR2 the linear address that triggers the fault." Since I
don't see CR0 bit 31 being set in your above code...maybe that's it. ;)
Post2: Braden, it looks like I may have misread your problem...sorry. To set up
a pointer to a function in D:
// Creates a void function pointer with void
// parameters, this matchs void _interrupt14()
void function( ) pt2Function;
// Assigns the function's address to the pointer
pt2Function = &_interrupt14;
// Then can call the function thru the point
pt2Function();
Hope I got it right this time?

Post2: Braden, it looks like I may have misread your problem...sorry. To set

a pointer to a function in D:
// Creates a void function pointer with void
// parameters, this matchs void _interrupt14()
void function( ) pt2Function;
// Assigns the function's address to the pointer
pt2Function = &_interrupt14;
// Then can call the function thru the point
pt2Function();
Hope I got it right this time?

You were right. If both functions were members of the same struct, then it
won't compile. If I make _interrupt14 global, then it compiles fine. Is there
any way around this? I'd rather not have a global function if possible.
___________________________________
struct Something {
void f1() {
void*
p2 = cast(void*)&_f2; // Error
void* p3 = cast(void*)&_f3; // OK
}
void
f2() {
//Something
}
}
void f3() {
//Something
}
___________________________________
In article
<c91cfg$mjj$1 digitaldaemon.com>, Walter says...

You were right. If both functions were members of the same struct, then it
won't compile. If I make _interrupt14 global, then it compiles fine. Is there
any way around this? I'd rather not have a global function if possible.
___________________________________
struct Something {
void f1() {
void*
p2 = cast(void*)&_f2; // Error
void* p3 = cast(void*)&_f3; // OK
}
void
f2() {
//Something
}
}
void f3() {
//Something
}

You'll have to make f2 static. As it stands, &f2 is 8 bytes long, not
four. (four for a pointer to the Something instance, four more for the
address of the method)
-- andy