|
|
On Tue, 25 Mar 2008 01:20:44 -0000, Peter Nilsson <airia@xxxxxxxxxxx>
wrote:
What about aggregates thereof?
The structure contains, in order, an 8-bit char, two sixteen-bit unsigned
ints, and an 8-bit char. No aggregates.
You are right to be concerned [about padding], but in thisspecific case,
all bits zero must represent zero for all
integral types in both C90 and C99.
True, but what about the padding areas?
This can be simplified to a single memset(acts, 0, ...).
But if you want robustness against one day having float or
pointer types, then you can do something like...
void clear_actions(ACTION act[], size_t N)
{
static const ACTION zero;
size_t i;
for (i = 0; i < N; i++)
act[i] = zero;
}
I like that, thanks.
--
Martin
|
|