I'm having trouble mocking some 3rd-party code; and I've been able to reduce it to a small example.
The input header:
- Uses a macro function to declare a struct type, and
- Has a static inline function
#include "foo_type.h"
struct FOO_TYPE(bar) { int baz; };
static inline char b(void) { return 0; }
The default behavior excludes static inline functions, so there is nothing to mock, i.e. cmock can correctly determine that struct FOO_TYPE(bar) { int baz; }; is not a function prototype.
To create mocks for static inline functions, I pass --treat_inlines=:include, which generates a correctly-normalized header file:
#include "foo_type.h"
struct FOO_TYPE(bar) { int baz; };
char b(void);
And successfully mocks b, but now cmock also tries to mock the struct type declaration, resulting in invalid syntax, e.g.:
void FOO_TYPE_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, bar cmock_arg1, struct cmock_to_return);
unknown type names ~~^ ~~^
This doesn't appear to have anything to do with the normalization of the original header file, since directly mocking the generated normalized header produces similar results (mocks b only when excluding inlines, but mocks b and FOO_TYPE when including inlines).
I'm having trouble mocking some 3rd-party code; and I've been able to reduce it to a small example.
The input header:
The default behavior excludes static inline functions, so there is nothing to mock, i.e. cmock can correctly determine that
struct FOO_TYPE(bar) { int baz; };is not a function prototype.To create mocks for static inline functions, I pass
--treat_inlines=:include, which generates a correctly-normalized header file:And successfully mocks
b, but now cmock also tries to mock the struct type declaration, resulting in invalid syntax, e.g.:This doesn't appear to have anything to do with the normalization of the original header file, since directly mocking the generated normalized header produces similar results (mocks
bonly when excluding inlines, but mocksbandFOO_TYPEwhen including inlines).