以下结构的正确顺序是什么?它的抛出字段有一个不完整的类型错误。
#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;
}发布于 2017-03-16 17:35:01
发布于 2017-03-16 17:33:28
您的结构包含一个类型为struct ucred的字段,该字段尚未在任何地方定义。
您需要为该类型提供定义。
发布于 2017-03-16 17:39:43
结构nl_msg中的一个字段
struct ucred nm_creds;具有未定义的数据类型;您尚未为ucred anywhere定义结构。您需要在代码中的某个位置定义结构ucred。这就是为什么您会得到错误:
字段存在不完整的类型错误。
如果您引用的是socket.h文件,则需要将头文件添加到定义此结构的代码中:
#include <sys/socket.h>编辑:您还需要定义_GNU_SOURCE宏。
https://stackoverflow.com/questions/42840998
复制相似问题