Snaipe / Mimick

A KISS, cross-platform C mocking library
MIT License
152 stars 43 forks source link

Can't #include mimick.c from a C++ source #14

Open jiridanek opened 4 years ago

jiridanek commented 4 years ago

When I try, I get compile errors of the type

mimick.h:36:26: error: conflicting declaration ‘typedef struct mmk_stub* mmk_stub’

In C++ the type names have to be disambiguated, such as mmk_stub_t, and so on.

jiridanek commented 4 years ago

Having overcome the reported issue, it looks like that is the least of my worries. Probably best to use mimick only in C code.

Snaipe commented 4 years ago

Feel free to cherry pick commits from https://github.com/Snaipe/Mimick/pull/13 -- I don't know if these 100% work, but I expect they'd at least let you compile.

I don't see any reason why mimick wouldn't work with C++ functions. Are you making sure the functions you're trying to mock are 1) not class methods and 2) that you're using mangled names when installing the mock (or marking the functions themselves extern "C"?)