c - 错误 : field ‘nm_creds’ has incomplete type

标签 c structure header-files

以下结构的正确顺序是什么?它的 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 。

See this online .

关于c - 错误 : field ‘nm_creds’ has incomplete type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42840998/

上一篇:c - 程序不工作

下一篇:c - 段错误 (C)

相关文章:

javascript:从结构中函数的范围访问结构中的父对象

c++ - 多次包含头文件导致编译时间变长?

c++ - 编译单个大头文件(VS : C1063)

c - getpwuid() 和 stat() 的问题

c - 如何计算c中的逆模幂?

c - gcc链接静态库中未解析符号的顺序是什么

c - function_name 之前出现错误 : expected ‘=’ , ‘,’ 、 ‘;’ 、 ‘asm’ 或 ‘__attribute__’

c - 结构填充和包装

c - c中的结构体链表

c++ - c++ : linker command failed 中头文件的问题