Problems with casting and function pointers
I thought I''d put this out again under a better title.
I''m following one of LaMothe''s older books (Black Art of 3D, and TGPG ) and in Black Art he writes a keyboard driver. Well, I thought I''d follow along, but am getting compiler errors about _dos_setvect. It goes as follows
// holds old keyboard interrupt handler (this is a function pointer)
void ( _interrupt _far* Old_Keyboard_ISR )(...);
...
_dos_setvect( KEYBOARD_INTERRUPT, Old_Keyboard_ISR );
ERROR: Cannot convert ''void(*)(...)'' to ''void (interrupt *)(...)''
The problem is trying to use _dos_setvect with the function pointer. If I declare my own interrupt function, I can set it fine, but it doesn''t want to take the function pointer that holds the old keyboard driver. And without this line my program crashes upon exit (duh!).
I tried
_dos_setvect( KEYBOARD_INTERRUPT, ( void (interrupt *)(...))Old_Keyboard_ISR )
but that doesn''t work.
I''m using Borland C++ 5.02 if that matters. Thanks for any suggestions.
Ut
PS.
If anyone has written a keyboard driver with C++ under DOS it might be helpful. I just need a way to restore the original keyboard driver. I''m currently looking for webpages about doing this, so if you know of any that would be good too. Thanks!
Ut
If anyone has written a keyboard driver with C++ under DOS it might be helpful. I just need a way to restore the original keyboard driver. I''m currently looking for webpages about doing this, so if you know of any that would be good too. Thanks!
Ut
I''m not 100% sure this is the solution, but have you tried something with "__cdecl" like:
PLease correct me if I''m wrong,
- Bas
void __cdecl (_interrupt _far* Old_Keyboard_ISR )(...);
PLease correct me if I''m wrong,
- Bas
_cdecl didn''t work.
I tried to ''extern "C"'' _dos_setvect, both with and without _cdecl and tried _cdecl on the Old_Keyboard_ISR variable. Still got the same error. Thanks though.
Ut
I tried to ''extern "C"'' _dos_setvect, both with and without _cdecl and tried _cdecl on the Old_Keyboard_ISR variable. Still got the same error. Thanks though.
Ut
Fixed it! Geesh! Turned out to be a parenthesis problem
void ( _interrupt _far* Old_Keyboard_ISR)(...);
should have been
void _interrupt _far (*Old_Keyboard_ISR)(...);
I''m guessing that by placing _interrupt inside the () it was not being "made" an interrupt function and getting lost. Placing it outside actually tells the compiler "this is a pointer to an _interrupt_ function".
Thanks to all that helped
Ut
void ( _interrupt _far* Old_Keyboard_ISR)(...);
should have been
void _interrupt _far (*Old_Keyboard_ISR)(...);
I''m guessing that by placing _interrupt inside the () it was not being "made" an interrupt function and getting lost. Placing it outside actually tells the compiler "this is a pointer to an _interrupt_ function".
Thanks to all that helped
Ut
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement