tags:

views:

134

answers:

3

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.

A: 

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

Windows programmer
I have no `#define`s. Also, before someone says I should paste the whole code, there are three files and some 500 lines.
piggles
+2  A: 

There is a missing ; at the end of:

struct DHTid{...}.

it should be:

struct DHTid{...};
I presume you mean `DHTnode`?unfortunately, it still gives me the same error. :/
piggles
No man, not DHTnode but DHTid. You've put a . instead of ;
I'm assuming he means DHTid, where you have left a dot, not a semicolon, after the structure. Note that if you take the time to say "My code actually looks like this", we'll take your word for it, problems and all.
Lasse V. Karlsen
Oh. I didn't realize that he didn't read the rest of it. I was under the impression that structure was a more abstract term in the English language than a photographic imprint.
piggles
+8  A: 

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.

AndreyT
*facepalm*. thanks. Also, thanks user318466
piggles