eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.23k stars 169 forks source link

FakeIt doesn't support packed classes #185

Open oriolarcas opened 4 years ago

oriolarcas commented 4 years ago

Hi,

I am trying to mock a class that manages binary data, and is compiled with the packed attribute to avoid padding between data fields.

For instance:

struct Test {
    int a;
    char b;

    virtual int get_a() = 0;
    virtual char get_b() = 0;
} __attribute__((packed));

The compile will fail in this assert:

static_assert(sizeof(C) == sizeof(FakeObject<C, baseclasses...>), "This is a problem");

I didn't find any documentation or issues, any ideas on how to solve it?

hedayat commented 4 years ago

Well, I guess this is not supported currently. It seems that special code for packed classes is needed.