马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
typedef struct {
ril_cmd_id_t cmd_id; /**< A unique ID */
ril_request_mode_t mode; /**< AT command mode, */
ril_result_code_t res_code; /**< Final response code */
void *cmd_param; /**< A pointer to the subparameter structure, user should cast it to the right data structure specified for each command. */
char *test_mode_str; /**< A pointer to the response string */
uint32_t test_mode_str_len; /**< The response string */
} ril_cmd_response_t;
typedef int (*ril_cmd_response_callback_t)(ril_cmd_response_t *response);
extern ril_status_t ril_request_query_network_state(ril_request_mode_t mode,
int32_t display_mode,
ril_cmd_response_callback_t callback,
void *user_data);
问题:1,我知道代码中ril_cmd_response_t是结构体,但是 typedef int (*ril_cmd_response_callback_t)(ril_cmd_response_t *response);又是什么?
2,如何读取 ril_cmd_response_callback_t定义的callback变量中的结构体成员?
3,谢谢
不可以,ril_cmd_response_t 和 ril_cmd_response_callback_t 这两个类型是完全不同的
还有,response变量没有初始化,这导致 callback 也没有指向正确的对象,把这个指针作为参数传递给 ril_request_query_network_state 函数肯定会出问题
ril_cmd_response_callback_t 这个类型的变量应该这样用 int test(ril_cmd_response_t *response) {
return 0;
}
int main(void) {
ril_cmd_response_t response;
ril_cmd_response_callback_t callback = test;
callback(&response);
return 0;
}
|