【发布时间】:2016-05-08 01:46:36
【问题描述】:
我遇到了 XCB 的问题。我不明白 *_reply_t 与 *_request_t 类型之间的区别。
似乎*_reply_t 代替*_response_t 传递,但结构非常不同。
例如:
xcb_randr_get_screen_resources_current_reply_t *reply = xcb_randr_get_screen_resources_current_reply(
connection, xcb_randr_get_screen_resources_current(connection, root), NULL);
所以现在reply 是*_reply_t 的类型。但现在我需要使用xcb_randr_get_screen_resources_current_outputs,它希望第一个参数的类型为xcb_randr_get_screen_resources_current_request_t,根据此处的文档:
http://www.linuxhowtos.org/manpages/3/xcb_randr_get_screen_resources_current_outputs.htm
xcb_randr_output_t *xcb_randr_get_screen_resources_current_outputs(
const xcb_randr_get_screen_resources_current_request_t *reply
);
但是,第一次调用的响应类型为 xcb_randr_get_screen_resources_current_reply_t (*_reply_t)。如何在不强制转换的情况下将其传递给输出调用?根据文档,结构完全不同:
typedef struct xcb_randr_get_screen_resources_current_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
uint16_t num_crtcs;
uint16_t num_outputs;
uint16_t num_modes;
uint16_t names_len;
uint8_t pad1[8];
} xcb_randr_get_screen_resources_current_reply_t;
*_request_t 的结构不在我从这里的源代码中获得的文档中:
https://xcb.freedesktop.org/manual/randr_8h_source.html#l00896
typedef struct xcb_randr_get_screen_resources_current_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_screen_resources_current_request_t;
我做 ctypes,所以我必须事先声明我要传入的类型,以用于方法的签名。所以我很困惑一个完全不同的结构(reply)如何进入第二个结构为request的调用。
【问题讨论】:
标签: xcb