小编Zer*_*day的帖子

C 双括号

我不知道这个“功能”叫什么,所以我也无法用谷歌搜索它,如果标题没有意义,我很抱歉。我最近查看了suckless dwm的源代码并看到了这段代码:(来自dwm.c)

static int (*xerrorxlib)(Display *, XErrorEvent *);
Run Code Online (Sandbox Code Playgroud)

还有这个:

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
};
Run Code Online (Sandbox Code Playgroud)

这是什么void (*handler[LASTEvent]) (XEvent *)意思 ?它叫什么以及为什么用它?

c function-pointers declaration ctor-initializer

2
推荐指数
1
解决办法
159
查看次数