结构类型本身可以作为c中的参数传递吗?

在研究wayland协议时,我发现函数将struct type作为参数。

#include  static struct wl_compositor_interface compositor_interface = {&compositor_create_surface, &compositor_create_region}; int main() { wl_global_create (display, &wl_compositor_interface, 3, NULL, &compositor_bind); } 

wl_global_create的签名是

 struct wl_global* wl_global_create (struct wl_display *display, const struct wl_interface *interface, int version, void *data, wl_global_bind_func_t bind) 

wl_compositor_interface是结构类型,而不是变量名。 但是wl_global_create()将结构类型作为函数参数。 谁能解释一下这是如何工作的?

我读到的源代码就在这里。 https://github.com/eyelash/tutorials/blob/master/wayland-compositor/wayland-compositor.c

我浏览了源代码,并且有一个struct wl_compositor_interface和一个变量wl_compositor_interface

包含的wayland_server.h在底部包含了wayland-server-protocol.h 。 不幸的是,这不是在线提供的,而是在构建时生成的。 你可以得到它:

 $ git clone git://anongit.freedesktop.org/wayland/wayland $ cd wayland $ mkdir prefix $ ./autogen.sh --prefix=$(pwd)/prefix --disable-documentation $ make protocol/wayland-server-protocol.h 

在这个文件中,它有(有些令人困惑)的定义:

 extern const struct wl_interface wl_compositor_interface; // On line 195 ... struct wl_compositor_interface { // Starting on line 986 void (*create_surface)(struct wl_client *client, struct wl_resource *resource, uint32_t id); void (*create_region)(struct wl_client *client, struct wl_resource *resource, uint32_t id); }; 

它是第一次引用的struct ,第二次是变量。