这段代码在C中意味着什么?

时间:2017-05-09 15:27:16

标签: c arrays initialization function-pointers

今天我正在阅读dwm源代码,在那里我遇到了这段代码:

static void (*handler[LASTEvent]) (XEvent *) = {
  [ButtonPress] = buttonpress,
  [ClientMessage] = clientmessage,
  [ConfigureRequest] = configurerequest,
  [ConfigureNotify] = configurenotify,
  [DestroyNotify] = destroynotify,
  [EnterNotify] = enternotify,
  [Expose] = expose,
  [FocusIn] = focusin,
  [KeyPress] = keypress,
  [KeyRelease] = keypress,
  [MappingNotify] = mappingnotify,
  [MapRequest] = maprequest,
  [MotionNotify] = motionnotify,
  [PropertyNotify] = propertynotify,
  [UnmapNotify] = unmapnotify
};

这是一个函数指针数组,我明白了。但为什么这样初始化?我的意思是初始化块中的所有括号值是什么?例如([ButtonPress] = buttonpress)

0 个答案:

没有答案