非常簡單的問題其中這樣的代碼工作嗎?C數組初始化範圍
static void *gostruct[] =
{
[0 ... 255] = &&l_bad,
['\t'] = &&l_loop, [' '] = &&l_loop, ['\r'] = &&l_loop, ['\n'] = &&l_loop,
['"'] = &&l_qup,
[':'] = &&l_loop,[','] = &&l_loop,
['['] = &&l_up, [']'] = &&l_down, // tracking [] and {} individually would allow fuller validation but is really messy
['{'] = &&l_up, ['}'] = &&l_down,
['-'] = &&l_bare, [48 ... 57] = &&l_bare, // 0-9
['t'] = &&l_bare, ['f'] = &&l_bare, ['n'] = &&l_bare // true, false, null
};
通過它其讀數清晰地看到,它含有初始化256項的數組的值& & l_bad然後覆蓋具有特定值某些索引。但是這個代碼不能在VS2010中編譯,這是我可以訪問的,所以我想知道這是有效的C代碼。
注意:此代碼片段取自JSON parser on github,據我瞭解,該代碼片段爲處理JSON字符串創建跳轉表。
我相信這是使用gcc擴展。 – Angelom