Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91752

Forum Post: RE: Help needed with ISR function ptr compiler error

$
0
0

FIrst I'll illustrate your error with a contrived example.

% type file.cpp void register_isr(void (*fxn)(int)); extern "C" void isr_handler(int);  void do_stuff() {    register_isr(isr_handler); }  % cl6x --verbose_diagnostics file.cpp "file.cpp", line 6: error: argument of type "void (*)(int) C" is incompatible           with parameter of type "void (*)(int)"      register_isr(isr_handler);                   ^  1 error detected in the compilation of "file.cpp".  >> Compilation failure

The fix is to make the type of the argument to register_isr match with the declaration for isr_handler.  There are two ways to do that.  One is to make register_isr extern "C".  

extern "C" {                               // new code here    void register_isr(void (*fxn)(int)); }  extern "C" void isr_handler(int);  void do_stuff() {    register_isr(isr_handler); }

The other method is to remove extern "C" from the declaration of isr_handler.

void register_isr(void (*fxn)(int)); void isr_handler(int);                // change here  void do_stuff() {    register_isr(isr_handler); }

I'm not sure which approach is best in your case.

Thanks and regards,

-George


Viewing all articles
Browse latest Browse all 91752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>