This code works and sets all members of a 2x4 array in one go:

Code:

typedef unsigned long long Biglong;
union Myunion
{
Biglong val;
uint8_t buf[2][4];
};
// then
cout << "foo_test 1.0" << endl;
union Myunion U;
memset(&U, 0, sizeof( union Myunion));
int x,y;
for(x = 0; x < 2; x++)
{
for(y = 0; y < 4; y++)
{
char out[255];
sprintf(out, "\tU[%d][%d] = %d\n", x, y, (int)U.buf[x][y]);
printf(out);
}
}
cout << "\n\nsetting all with one single command..." << endl;
Biglong l = 18446744073709551615;
U.val = l;
for(x = 0; x < 2; x++)
{
for(y = 0; y < 4; y++)
{
char achOut[255];
sprintf(achOut, "\tU[%d][%d] = %d\n", x, y, (int)U.buf[x][y]);
printf(achOut);
}
}
return 0;

Produces:

Code:

foo_test 1.0
U[0][0] = 0
U[0][1] = 0
U[0][2] = 0
U[0][3] = 0
U[1][0] = 0
U[1][1] = 0
U[1][2] = 0
U[1][3] = 0
setting all with one single command...
U[0][0] = 255
U[0][1] = 255
U[0][2] = 255
U[0][3] = 255
U[1][0] = 255
U[1][1] = 255
U[1][2] = 255
U[1][3] = 255
j