Strange array initialize expression?

后端 未结 3 688
粉色の甜心
粉色の甜心 2020-11-30 10:15

What is the meaning of following Code? Code is from the regression test suite of GCC.

static char * name[] = {
   [0x80000000]  = \"bar\"
};
3条回答
  •  被撕碎了的回忆
    2020-11-30 10:19

    It's called designated initializer which is introduced in C99, gcc also supports it in GNU89 as an extension, see here for detail.

     int a[6] = { [4] = 29, [2] = 15 };
    

    is equivalent to

     int a[6] = { 0, 0, 15, 0, 29, 0 };
    

提交回复
热议问题