static struct inet_protosw inetsw_array[] =
{
[0] = { /* assignment by index */
.type = SOCK_STREAM, /* assignment by field */
.protocol = IPPROTO_TCP,
.prot = &tcp_prot,
.ops = &inet_stream_ops,
.no_check = 0,
.flags = INET_PROTOSW_PERMANENT |
INET_PROTOSW_ICSK,
},
}
上述代碼在C中工作,但不在C++中工作。我認爲這兩種方法非常好。 C++如何刪除它?通過索引或字段分配在C++中不起作用
PS:看來字段賦值可以實現: 類型:SOCK_STREAM
更多關於此,http://stackoverflow.com/questions/4900739/why-are-designated-initializers-not-implemented-in-g – jweyrich