TTimo / GtkRadiant

The open source, cross platform level editor for idtech games
http://icculus.org/gtkradiant/
Other
582 stars 152 forks source link

Use flexible array members #582

Closed tkoeppe closed 6 years ago

tkoeppe commented 6 years ago

Change winding_t, winding_accu_t and brush_t to use flexible array members rather than fixed-sized arrays.

The arrays were always meant to be variably sized, and objects are only ever allocated dynamically. Object size computations are simplified with this change.

Flexible arrays were introduced in C99, so this change means that we will require a C99-conforming compiler henceforth.

I leave it up to you to decide whether that's acceptable, and whether the build system needs changing. I think GCC changed its defaults to C11 and C++14 in version 6, but for other compilers we should probably add an explicit -std=c99 flag.

Following this change, we may like to replace offsetof by sizeof where appropriate, since sizeof is well-defined for flexible arrays to achieve exactly what we have been doing with offsetof so far. But I haven't tested that particular change yet, so that'll come separately.

(See also https://github.com/TTimo/bspc/pull/11.)