首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C:字段类型不完整

C:字段类型不完整
EN

Stack Overflow用户
提问于 2013-06-25 15:12:20
回答 4查看 56.3K关注 0票数 13

如果之前有人问过这个问题,我向您道歉。

在通过make编译时,我得到了以下错误:

代码语言:javascript
运行
复制
.../inc/intModIp.h:418: error: field 'cnc_id' has incomplete type
../inc/intModIp.h:419: error: field 'cnc_key' has incomplete type
../inc/intModIp.h:421: error: field 'fin_id' has incomplete type
../inc/intModIp.h:422: error: field 'fin_key' has incomplete type
../inc/intModIp.h:424: error: field 'remote_id' has incomplete type
../inc/intModIp.h:426: error: field 'cnc_ipsec_peer' has incomplete type
../inc/intModIp.h:427: error: field 'fin_ipsec_peer' has incomplete type
../inc/intModIp.h:428: error: field 'remote_ipsec_peer' has incomplete type
../inc/intModIp.h:430: error: field 'cnc_link' has incomplete type
../inc/intModIp.h:431: error: field 'cnc_esp' has incomplete type
../inc/intModIp.h:433: error: field 'fin_link' has incomplete type
../inc/intModIp.h:434: error: field 'fin_esp' has incomplete type

头文件中的各个代码如下:

代码语言:javascript
运行
复制
#if 1 || defined(SYMB_IPSEC)
    struct ipsec_state {
        int enabled;
        int active;
        int timer;
/* IPSEC_SOCKET_STATES */

        struct ipsec_id cnc_id;
        struct ipsec_priv_key cnc_key;

        struct ipsec_id fin_id;
        struct ipsec_priv_key fin_key;

        struct ipsec_id remote_id;

        struct ipsec_peer cnc_ipsec_peer;
        struct ipsec_peer fin_ipsec_peer;
        struct ipsec_peer remote_ipsec_peer;

        struct ipsec_ike_link cnc_link;
        struct ipsec_esp_sa cnc_esp;

        struct ipsec_ike_link fin_link;
        struct ipsec_esp_sa fin_esp;
    } ipsec;
#endif

有人能帮我一下吗。如果需要任何其他信息,请让我知道。

谢谢,桑尼

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-06-25 15:32:17

问题可能是所有这些结构都是向前声明的。

标题是否包含在struct ipsec_state之后?:

/* a.h */

代码语言:javascript
运行
复制
struct a {
    int i;
};

/* demo.c */

代码语言:javascript
运行
复制
struct b {
    struct a A;
};

#include "a.h"

int main(void)
{
    return 0;
}

输出:

代码语言:javascript
运行
复制
david@debian:~$ gcc -std=c99 -Wall -pedantic -W -Wextra -o demo demo.c
demo.c:2:11: error: field ‘A’ has incomplete type
票数 9
EN

Stack Overflow用户

发布于 2013-06-25 15:16:36

编译器找不到声明的结构定义(ipsec_id ... ipsec_esp_sa ),您可能需要包含相关的头文件

票数 4
EN

Stack Overflow用户

发布于 2014-03-02 13:56:03

该错误的一个来源(字段的类型不完整)是在别名(通过typedef定义的变量)前面使用struct关键字时。尝试删除struct关键字。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17291268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档