Having trouble porting interupts from C to C++

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Having trouble porting interupts from C to C++

跳至解决方案
1,563 次查看
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 项奖励
回复
1 解答
1,356 次查看
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 项奖励
回复
2 回复数
1,357 次查看
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 项奖励
回复
1,356 次查看
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