Having trouble porting interupts from C to C++

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Having trouble porting interupts from C to C++

Jump to solution
627 Views
derekdrost
Contributor III

Attached is a picture with pretty much the problem I'm having.

At a loss what to do to match the argument.

Thanks in advance for the help

Derek

0 Kudos
1 Solution
420 Views
c0170
Senior Contributor III

Hello Derek Drost,

the error shown by CodeWarrior explains it clearly. I'll give you a hint, how does the left function differs from the right function? You will find an answer in the picture you shared :smileywink:

MQX is C library, therefore the function _int_install_isr expects the second parameter as a function pointer (void (*)(void *)). Unfortunately, what you attempt to do , install a class method as a callback. Which is not the same (this pointer as part of parameters).

Change the function to static, which will be not part of the class (no this pointer as a parameter). Although you can't access class member from static function. As I checked your code, that does not concern you.

More answers in C++ FAQ:

How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that s...

Regards,

c0170

View solution in original post

0 Kudos
2 Replies
421 Views
c0170
Senior Contributor III

Hello Derek Drost,

the error shown by CodeWarrior explains it clearly. I'll give you a hint, how does the left function differs from the right function? You will find an answer in the picture you shared :smileywink:

MQX is C library, therefore the function _int_install_isr expects the second parameter as a function pointer (void (*)(void *)). Unfortunately, what you attempt to do , install a class method as a callback. Which is not the same (this pointer as part of parameters).

Change the function to static, which will be not part of the class (no this pointer as a parameter). Although you can't access class member from static function. As I checked your code, that does not concern you.

More answers in C++ FAQ:

How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that s...

Regards,

c0170

0 Kudos
420 Views
Martin_
NXP Employee
NXP Employee

In many cases such issues are caused by C++ name mangling. As seen from a C module, the name won't be isrDataReady, but most likely the C++ compiler will take the function parameters into consideration, something like isrDataReady_v. .

https://community.freescale.com/message/316004#316004