开发者

What makes this struct incomplete?

gcc lovingly throws me this error:

bst.c:33: error: invalid application of ‘sizeof’ to incomplete type ‘struct BSTNode’

What makes BSTnode incomplete? Below are the struct definitions relevant to BSTnode.

struct BSTnode{

    struct BSTnode * left;
    struct BSTnode * right;

    struct hash minhash;
    struct hash maxhash;

    struct DHTid owner;
    int misses;
};
开发者_开发百科

where we have:

struct hash{
    int hash;
};

struct DHTid
{
    int islocal;

    unsigned long addr;
    unsigned short port;
    struct DHTnode * node;
};

and currently:

struct DHTnode{
    int something;
};

EDIT: My actual code has the following structure:

struct DHTnode{...};
struct hash{...};
struct DHTid{...}; /*changed . to ; in pseudocode*/
struct BSTnode{...};

EDIT: user318466 pointed a missing semicolon, but there was still more wrong with it.


You declared type struct BSTnode. You are applying sizeof to type struct BSTNode. Note the difference in capitalization: n and N. struct BSTNode is, of course, a completely unknown to the compiler incomplete type, which is what it is telling you.


There is a missing ; at the end of:

struct DHTid{...}.

it should be:

struct DHTid{...};


Your header files probably #define one of your identifiers to be something you don't want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜