reply_t vs request_t - 交替传递它们?

reply_t vs request_t - passing them in interchangeably?

我在使用 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.

的第二次调用的

我认为您偶然发现的只是一个文档错误。所有声称采用 *_request_t 的函数实际上期望 *_reply_t。从您链接的来源,只需查看实际的函数定义(而不是手册页所说的),您就会发现

xcb_randr_output_t *
    xcb_randr_get_screen_resources_current_outputs (const xcb_randr_get_screen_resources_current_reply_t *R  );

您找到的结构实际上并没有在文件中的任何地方使用,所以它可能是一些遗忘的遗留物,或者出于兼容性原因可能仍然保留着。