0

I am having a problem with a case where i have created a C function that is passed to another library as a callback, so it uses CALLBACK notation. this is using VS2015.

VOID CALLBACK TheCallback(void)

i am unit testing some code using unity and cmock and I am trying to mock the callback..

so, when cmock scripts create all of the mocks (the mock header file) it creates lines like this:

void TheCallback_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, VOID CALLBACK cmock_to_return);

(note the word CALLBACK in there)

and when i compile i get warnings and errors like this:

warning C4229: anachronism used: modifiers on data are ignored

error C2182: 'cmock_to_return': illegal use of type 'void'

It seems to have to do with that CALLBACK stuck right in the middle.

any ideas at all on how i can declare this as a CALLBACK and not have VS2015 complain about the type in the function prototype of the ignore and return mock?

i am wondering if i need to somehow undefine CALLBACK when unit testing, not sure if i can even

Any ideas would be great.. Thank You.

scirdan
  • 59
  • 7

1 Answers1

1

To do this, you add CALLBACK to the list of "c calling conventions"

:cmock:
    :c_calling_conventions:
        - CALLBACK

or in cmock_config.rb, add CALLBACK::

:c_calling_conventions       => ['__stdcall', '__cdecl', '__fastcall', 'CALLBACK'],
scirdan
  • 59
  • 7