The requirement is to clear everything in the integers section, or
everything in the floats section?
The simple way is to individually clear {a,b,c,d,ei/ef} or {ei/ef,f,g,h}.
Another way is to duplicate the layout of {a,b,c,d,ei/ef} and
{ei/ef,f,g,h} as I tried above (paying attention to alignments and
padding). This defines object layouts that match your two sections.
Another way is to divide your overlapping sections into three lots, each
of which may be wrapped in an anonymous struct: A, B, C where section
integers is {A, B}, and section floats is {B, C}. And A is {a,b,c,d}, B
is {ei/ef} and C is {f,g,h}.
Then you do reset A; reset B, or reset B; reset C.
I'm sure other people can came up with many ways of actually performing
the task.
But devising a scheme for arbitrary, overlapping overlays to be added as
a totally new language feature is quite hard to do, it will look ugly,
and it will be confusing.
If you want a more general approach within the current language, try this:
#define integers_sect a,f
#define floats_sect ei,i // dummy zero-size field after h
struct SExample X;
reset_section(&X,getoffsets(struct SExample,integers_sect));
where:
#define getoffsets(T,a,b) offsetof(T,a),offsetof(T,b)-offsetof(T,a)
This should yield 'x,y' where x is the start offset of the section, y is
the size in bytes. The reset_section call becomes:
reset_section(&X, 24, 16);
for example. (This can map to memset((char*)&X+24,0,16).)
I've no idea whether this would work, but this anyway has the problem of
needing a struct field one past the end of the 'section'.
But I think it won't appeal to you because the information that defines
the sections is defined outside, separately from the struct.
--
bart