Closed johnflux closed 4 years ago
This is expected behavior but there is a viable work-around for it probably. I'll check Sunday!
Big project at work, sorry about that! So the above error is expected. You'll need to change the location of MyBitmap
to the end due to the union used by CK_BITMAP_INSTANCE. Is that a viable option for you to unblock you immediately?
Otherwise, a simple fix is to just do pointer casting in CK_BITMAP macros, which removes the need to rely on the union + FAM. I would want to additional safety checks for that and make sure it doesn't break too annoyingly for existing consumers (it's convenient now for us to be to reference .bitmap
on a bitmap instance, removing union would make that annoying but it can be solved with a new convenience macro).
The last option is we can also just use 0-sized array for the bitmap definition itself (change struct ck_bitmap
from map[]
to map[0]
. We won't be taking this route as it does prevent certain classes of bugs.
Patches are also welcome for this, happy to review.
I'm trying to compile some other codebase that uses ck, and it no longer compiles (breaks with gcc >6) because of the way that they've used ck.
Here is a small self-contained snippet:
The compile error is:
/usr/include/ck_bitmap.h:119:15: error: flexible array member ‘ck_bitmap::map’ not at end of ‘struct Foo’
My question is: Should this work, and is there an easy fix? Thanks.