ThrowTheSwitch / CMock

CMock - Mock/stub generator for C
http://throwtheswitch.org
MIT License
672 stars 273 forks source link

Error When Mocking Function with Function Pointer Parameter #385

Closed ian-678 closed 2 years ago

ian-678 commented 2 years ago

I was trying to mock a header that contained the following function declaration. int attr_assign_broadcast_cb( enum attr_group group, void (*cb_func) );

The brackets around (cb_func) seem to cause issues when creating the cmock functions. You can see this in the following error where an extra bracket is added to the _Depth parameter. error: conflicting types for 'cb_func' 684 | void __wrap_attr_assign_broadcast_cb_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, enum attr_group group, void( cb_func), int cb_func)_Depth, int cmock_to_return);

I did find a work around for the issue by using a typedef for the function pointer as that eliminated the extra brackets from the function declaration.

Ian

ian-678 commented 2 years ago

It looks like this issue is already captured in issue #349, closing.