我想知道以下语法的作用:
func((some_type*) apointer)
这是一个简单的类型检查还是做更多的事情?为什么类型周围需要括号?
来自http://nikhilm.github.com/uvbook/networking.html#tcp的整个示例:
int main() {
loop = uv_default_loop();
uv_tcp_t server;
uv_tcp_init(loop, &server);
struct sockaddr_in bind_addr = uv_ip4_addr("0.0.0.0", 7000);
uv_tcp_bind(&server, bind_addr);
/* here it is */
int r = uv_listen((uv_stream_t*) &server, 128, on_new_connection);
if (r) {
fprintf(stderr, "Listen error %s\n", uv_err_name(uv_last_error(loop)));
return 1;
}
return uv_run(loop, UV_RUN_DEFAULT);
}
问候, 博多
更新:
这能行吗?
typedef struct one_t
{
int counter;
} one_t;
typedef struct two_t
{
another_t request;
} two_t;
(one_t*) two_t