I am trying to initialize a 2D array of user defined type to zero by using following line,
qmf_t X_hybrid_left[32][32] = {{0}};
Where qmf_t
is a user defined type. Here I get the compiler warning,
warning: missing braces around initializer [-Wmissing-braces]"
But if I use, qmf_t X_hybrid_left[32][32] = {{{0}}};
, i.e. 3 braces each side, warning disappears.
Is it correct to use three braces on each side? What does it mean?
From C11 specs, 6.7.9 Initialization grammar
Although in your particular case (zeroing all objects of 2 arrays),
qmf_t X_hybrid_left[32][32] = {0};
will work same asqmf_t X_hybrid_left[32][32] = {{{0}}};
but compiler may warn you.But if you want any non-zero initialization, you need to use multiple braces.
From the same section: