meekrosoft / fff

A testing micro framework for creating function test doubles
Other
761 stars 167 forks source link

Const pointer as argument causes _Wcast-qual warnings #72

Open tk8b opened 5 years ago

tk8b commented 5 years ago

When using the fake function framework to mock a function that takes a const pointer as Argument, e.g.

FAKE_VOID_FUNC(my_function, int *const)

I get four compiler warnings:

fff.h:66:12: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] memcpy((void*)&FUNCNAME##_fake.arg##n##_val, (void*)&arg##n, sizeof(arg##n));

fff.h:66:50: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] memcpy((void*)&FUNCNAME##_fake.arg##n##_val, (void*)&arg##n, sizeof(arg##n));

fff.h:76:12: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] memcpy((void*)&FUNCNAME##_fake.arg##ARGN##_history[FUNCNAME##_fake.call_count], (void*)&arg##ARGN, sizeof(arg##ARGN));

fff.h:76:85: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] memcpy((void*)&FUNCNAME##_fake.arg##ARGN##_history[FUNCNAME##_fake.call_count], (void*)&arg##ARGN, sizeof(arg##ARGN));

As I read through the documentation and through merged pull requests, it seems this should be possible. Am I doing something wrong, or do I have to life with the warnings?