C:字段类型不完整

Sun*_*nny 11 c makefile

如果以前曾经问过,我道歉.

通过make编译时出现以下错误:

.../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
Run Code Online (Sandbox Code Playgroud)

头文件中的相应代码如下:

#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
Run Code Online (Sandbox Code Playgroud)

有人可以帮我这个.如果需要任何其他信息,请告诉我.

谢谢,Sunny

Dav*_*eri 8

问题可能是所有这些结构都被宣布为前进.

是否包含标题struct ipsec_state?:

/*啊*/

struct a {
    int i;
};
Run Code Online (Sandbox Code Playgroud)

/*demo.c*/

struct b {
    struct a A;
};

#include "a.h"

int main(void)
{
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

david@debian:~$ gcc -std=c99 -Wall -pedantic -W -Wextra -o demo demo.c
demo.c:2:11: error: field ‘A’ has incomplete type
Run Code Online (Sandbox Code Playgroud)