Having trouble porting interupts from C to C++

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Having trouble porting interupts from C to C++

ソリューションへジャンプ
757件の閲覧回数
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 解決策
550件の閲覧回数
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 返答(返信)
551件の閲覧回数
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 件の賞賛
返信
550件の閲覧回数
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