以下结构的正确顺序是什么?它的 throw 字段有一个不完整的类型错误。
#include <stdlib.h>
struct nl_msg
{
int nm_protocol;
int nm_flags;
struct ucred nm_creds;
struct nlmsghdr * nm_nlh;
size_t nm_size;
int nm_refcnt;
};
struct nl_msg;
struct nl_tree;
struct ucred;
int main()
{
return 0;
}
最佳答案
在您的代码中(更确切地说,翻译单元。),没有任何地方定义 struct ucred
。
您需要定义_GNU_SOURCE
MACRO 并包含sys/socket.h
定义此结构的 header 。
关于c - 错误 : field ‘nm_creds’ has incomplete type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42840998/