最佳答案
我的结构如下:
struct app_data
{
int port;
int ib_port;
unsigned size;
int tx_depth;
int sockfd;
char *servername;
struct ib_connection local_connection;
struct ib_connection *remote_connection;
struct ibv_device *ib_dev;
};
当我尝试这样初始化它时:
struct app_data data =
{
.port = 18515,
.ib_port = 1,
.size = 65536,
.tx_depth = 100,
.sockfd = -1,
.servername = NULL,
.remote_connection = NULL,
.ib_dev = NULL
};
我得到了这个错误:
sorry, unimplemented: non-trivial designated initializers not supported
我认为它希望初始化的顺序与声明的一样,而 local_connection
缺失了。但是我不需要初始化它,并且将它设置为 NULL 也不起作用。
如果我把 g + + 改成这样,仍然会得到相同的错误:
struct app_data data =
{
port : 18515,
ib_port : 1,
size : 65536,
tx_depth : 100,
sockfd : -1,
servername : NULL,
remote_connection : NULL,
ib_dev : NULL
};